I am having trouble creating a dynamic statement in a Rails ERB template. This is essentially what I'm trying to do:
<%= photo.@photo_col.url %>
This will make the statement dynamic based on this condition in the controller:
if !params[:cat]
@my_photos = BusinessPhoto.where(contributor_id: session[:user_id])
@photo_col = "business_photo"
elsif params[:cat] && params[:cat] == "event"
@my_photos = EventPhoto.where(contributor_id: session[:user_id])
@photo_col = "event_photo"
elsif params[:cat] && params[:cat] == "blog"
@my_photos = BlogPhoto.where(contributor_id: session[:user_id])
@photo_col = "post_photo"
end
Can anyone see a problem with this statement?
params[:cat] &&without breaking anything. It has no practical effect here.