ruby on rails - Couldn't find Wiki without an ID error? -
i making wiki clone app in ruby on rails , trying destroy wiki, after click on destroy link error:
couldn't find wiki without id
and has problems code block
def destroy @wikis = wiki.all @wiki = wiki.find(params[:wiki_id]) @collaborator = @wiki.users.find(params[:user_id]) authorize @wiki end
where call delete function in wiki#views file. link looks this:
<%= link_to "delete wiki", @wiki, method: :delete, class: 'btn btn-danger', data: { confirm: 'are sure want delete wiki?' } %>
this error caused following line:
@wiki = wiki.find(params[:wiki_id])
params[:wiki_id]
nil
. you're doing this:
@wiki = wiki.find(nil)
in case find
throw error you're seeing, since cannot find records id of nil
.
as per tadman's suggestion, try changing line following:
@wiki = wiki.find(params[:id])
Comments
Post a Comment