I already had an issue with devise that i posted here : Weird route malfunction, mix between devise and own controller
I was hoping it was just a one time issue but devise is driving me crazy !
If I do this everything is ok
<% if user_signed_in? %>
<% if current_user.ideas.include?(@idea) %>
<%= button_to 'Remove from Favorites', user_idea_subscription(@idea.id), method: :delete%>
<% else %>
<%= button_to 'Add to Favorites', user_idea_subscriptions_path(current_user, :idea_id => @idea) %>
<% end %>
<% end %>
But if I do this :
<% if user_signed_in? and current_user.ideas.include?(@idea) %>
<%= button_to 'Remove from Favorites', user_idea_subscription(@idea.id), method: :delete%>
<% else %>
<%= button_to 'Add to Favorites', user_idea_subscriptions_path(current_user, :idea_id => @idea) %>
<% end %>
Then I’ve got this error :
No route matches {:controller=>"idea_subscriptions", :idea_id=>#<Idea id: 12, name: "Chute libre", description: "50sec a 50m/s", created_at: "2012-07-12 10:02:30", updated_at: "2012-07-12 10:02:30">}
Everything should be ok but why I’m getting that error ? (beside there is no other information on the error)
Thanks for your help and my sanity !
I think it is normal behaviour because in second case you are trying to call
then user is not signed in, so
current_useris nil