ruby - rails show page not showing associated record in rails 4 -
i have groups , have members(links).
my show page group used list members.
this worked fine in rails 3
i upgraded rails 4 , else works list of @members doesn't show , don't see error. regular erb page (i also, separately, have page content loaded through ajax should list members , broken, i'm focusing on erb page now).
the log shows
started "/groups/49" 127.0.0.1 @ 2014-08-18 20:34:25 -0400 processing groupscontroller#show html parameters: {"id"=>"49"} group load (0.4ms) select `groups`.* `groups` `groups`.`id` = 49 order group_name limit 1 (0.5ms) select count(*) `links` ('group_id') cache (0.0ms) select count(*) `links` ('group_id') cache (0.0ms) select count(*) `links` ('group_id') rendered groups/show.html.haml within layouts/application (5.5ms) the link is: link_to 'members', group
the routes are:
resources :groups resources :links # enables group/:id/link/new collection post 'order_links' end end the groups controller has following show:
def show @group = group.find(params[:id]) @members = link.where(:group_id, params[:id]).order(:position) respond_to |format| format.html # show.html.erb format.xml { render xml: @group } format.json { render json: @members } end end and page has:
%ul#sortable - @members.each |loop| = content_tag_for :li, loop - construct_hyperlink(loop.url_address, loop.alt_text) = sanitize @address_url \- #{h @new_link_alt_text} #{link_to 'details', link_path(loop), {"title" => loop.alt_text}} #{link_to 'edit', edit_link_path(loop), {"title" => loop.alt_text}} that's bit hard read grant you, rest assured it's been working in rails 3 years in app :)
maybe problem getting information associated model?
you have typo in where clause. this:
link.where(:group_id, params[:id]).order(:position) should become:
link.where(group_id: params[:id]).order(:position)
Comments
Post a Comment