if there's only one item search result, redirect to it
This commit is contained in:
parent
4c208c9ac3
commit
72c59f0b68
2 changed files with 10 additions and 2 deletions
|
@ -18,8 +18,12 @@ class ItemsController < ApplicationController
|
|||
assign_closeted!
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@items.prepare_partial(:item_link_partial)
|
||||
render
|
||||
if @items.size == 1
|
||||
redirect_to @items.first
|
||||
else
|
||||
@items.prepare_partial(:item_link_partial)
|
||||
render
|
||||
end
|
||||
}
|
||||
format.json {
|
||||
@items.prepare_method(:as_json)
|
||||
|
|
|
@ -7,6 +7,10 @@ class Item
|
|||
|
||||
delegate :description, :name, :nc?, :thumbnail_url, :to_param, to: :item
|
||||
|
||||
def self.model_name
|
||||
Item.model_name
|
||||
end
|
||||
|
||||
def initialize(id)
|
||||
@id = id
|
||||
@known_outputs = {method: {}, partial: {}}
|
||||
|
|
Loading…
Reference in a new issue