forked from OpenNeo/impress
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!
|
assign_closeted!
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
if @items.size == 1
|
||||||
|
redirect_to @items.first
|
||||||
|
else
|
||||||
@items.prepare_partial(:item_link_partial)
|
@items.prepare_partial(:item_link_partial)
|
||||||
render
|
render
|
||||||
|
end
|
||||||
}
|
}
|
||||||
format.json {
|
format.json {
|
||||||
@items.prepare_method(:as_json)
|
@items.prepare_method(:as_json)
|
||||||
|
|
|
@ -7,6 +7,10 @@ class Item
|
||||||
|
|
||||||
delegate :description, :name, :nc?, :thumbnail_url, :to_param, to: :item
|
delegate :description, :name, :nc?, :thumbnail_url, :to_param, to: :item
|
||||||
|
|
||||||
|
def self.model_name
|
||||||
|
Item.model_name
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(id)
|
def initialize(id)
|
||||||
@id = id
|
@id = id
|
||||||
@known_outputs = {method: {}, partial: {}}
|
@known_outputs = {method: {}, partial: {}}
|
||||||
|
|
Loading…
Reference in a new issue