ruby on rails - Record Not Found Error: Couldn't find List without an ID -
i'm building basic type app lists, each of has_many items. i'm trying construct view delegated tasks (sharing/tasks.html.erb) show items have been marked delegated. here relevant code on tasks.html.erb page:
<h2 class="text-center">delegated me</h2> <% @deligated_to_me.each |item| %> <p><%= link_to list_path(@list) %> <%= item.name %> <% end %> (deligated <%= item.user_id %>)</p> <% end %> and here sharing_controller section tasks page:
def tasks @lists = list.all @list = list.friendly.find(params[:list_id]) <<<<error called on line @items = item.all @delegated_to_me = @items.where(:delegated_to == current_user.email) @delegated_by_me = current_user.items.where.not(delegated_to: "") end when try view page record not found error saying couldn't find list without id. i've seen on other posts problem variable isn't declared in controller, doesn't seem case here. can me troubleshoot?
additional info: routes
list_items /lists/:list_id/items(.:format) items#index post /lists/:list_id/items(.:format) items#create new_list_item /lists/:list_id/items/new(.:format) items#new edit_list_item /lists/:list_id/items/:id/edit(.:format) items#edit list_item /lists/:list_id/items/:id(.:format) items#show patch /lists/:list_id/items/:id(.:format) items#update put /lists/:list_id/items/:id(.:format) items#update delete /lists/:list_id/items/:id(.:format) items#destroy lists /lists(.:format) lists#index post /lists(.:format) lists#create new_list /lists/new(.:format) lists#new edit_list /lists/:id/edit(.:format) lists#edit list /lists/:id(.:format) lists#show patch /lists/:id(.:format) lists#update put /lists/:id(.:format) lists#update delete /lists/:id(.:format) lists#destroy sharing_lists /sharing/lists(.:format) sharing#lists sharing_tasks /sharing/tasks(.:format) sharing#tasks
replace @list item.list
<h2 class="text-center">delegated me</h2> <% @deligated_to_me.each |item| %> <p> <%= link_to list_path(item.list) %> <%= item.name %> <% end %> (deligated <%= item.user_id %>) </p> <% end %> and remove code controller.
@list = list.friendly.find(params[:list_id])
Comments
Post a Comment