I’am still trying to make a system that gives users acces to edit their
own posts.
I build furtjer from the 32 of the rails recipe book called autorizing
users with roles.
So i create no a piece of code that does something but not the right
thing.
It’s only a test flash notice i don’t know wich code i must use
def check_priviliges
user = @session['user']
unless user.adverts.detect{|advert|
flash[:notice] = "right account i must find a way to give users
to edit theri post"}
flash[:notice] = “wrong accont”
redirect_to :controller => “account”, :action => “login”
return false
end
end
This does nothing at the moment but the problem is when a user clicks on
edit he always get the first flash notice when he has at least one post.
Maybe it sound a little bit stupid, so i have very little experience
with programming. Ruby on Rails is my first language.
I must always find a way to tell the program what it must do when
user.adverts.detect{|advert| is correct.
Maybe i must find the solotion elsewhere than in recipe 32. In this week
i get a solotion from soemone but that was for another user system i
guess.
ror this i have a table adverts_users in the database that works well it
gets the right rows at eac post.