Ruby on rails 显示组路径(@group)时出错
现在,我尝试使用group_path(@group)设置路由,但收到如下错误消息:Ruby on rails 显示组路径(@group)时出错,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.2,现在,我尝试使用group_path(@group)设置路由,但收到如下错误消息: ActiveRecord::RecordNotFound at /groups/%23%3CActiveRecord::Relation:0x007fd6cf362538%3E Couldn't find Group with id=#<ActiveRecord::Relation:0x00fds6cf362538> 替换 <% @group = Group.where(:isbn =>
ActiveRecord::RecordNotFound at /groups/%23%3CActiveRecord::Relation:0x007fd6cf362538%3E
Couldn't find Group with id=#<ActiveRecord::Relation:0x00fds6cf362538>
替换
<% @group = Group.where(:isbn =>isbn) %>
isbn)%%>
与
isbn)。第一个%>
因为您需要一个具有ActiveRecord关系的对象您在修改路由后重新启动了吗?还要注意“id=#”部分,Apreading先生,非常感谢!!多亏了你,我才能解决这个问题。
def index
@keyword = params[:keyword]
if @keyword.present?
Amazon::Ecs.debug = true
res = Amazon::Ecs.item_search(params[:keyword],
:search_index => 'All', :response_group => 'Medium')
@items = res.items
search_isbns = @items.map{ |isbns| isbns.get('ItemAttributes/ISBN')}
search_asins = @items.map{ |asins| asins.get('ItemAttributes/ASIN')}
@existing_groups_isbns = Group.select(:isbn).where(:isbn => search_isbns).map(&:isbn)
@existing_groups_ids = Group.where(:isbn => search_isbns).map{|g| g.id}
end
<% @group = Group.where(:isbn =>isbn) %>
<% @group = Group.where(:isbn =>isbn).first %>