I want to compare @question.id with value in a database table Work. How can I do that inside the show action of the question controller?
I want to compare @question.id with @community.community_activity, but when I do that inside the question controller the @community is nil:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.community_activity
How to tackle this???
if @question.id != @community.community_activity.for_communities(60).object_id and current_user.role.title.strip == "Test"
redirect_to 'public/access_denied.html'
return
Based on what you are showing us, all I can suggest is the following:
Or maybe this is more appropriate: