Reputation: 502
I've been playing around with my if and else statement but it's always just providing one.
First try
<% if @albumable == @user %>
<%= link_to "Edit", edit_community_album_path(@albumable, album), class: "album_edit" %>
<% else %>
<%= link_to "Ediiiit", edit_user_album_path(@albumable, album), class: "album_edit" %>
<% end %>
Second try
<% if @community == @community_id %>
Albumable will either be a user_id or community_id. When I play around with the code I only get 1 result from the two for both the user album edit page and the community album edit page. I don't understand how I'll be able to making an if statement if it isn't within the community page, it should produce the else statement. All help is appreciated, thank you.
Upvotes: 0
Views: 43
Reputation: 1050
I would suggest refactoring this code to remove the if/else statement altogether. For example, the following provides the exact same functionality:
<%= link_to "Edit", [:edit, @albumable, album], class: "album_edit" %>
You can read more about this at http://guides.rubyonrails.org/routing.html#creating-paths-and-urls-from-objects
Upvotes: 1
Reputation: 2743
Compare the id
values instead. Depending on how you loaded those variables with records, Ruby might not think they're equal.
Upvotes: 0