Hello, How can I do, when a user make a post, he only can edit his posts? thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Jan 10, 2010 at 11:30 AM, Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, How can I do, when a user make a post, he only can edit his > posts? >Check for the owner of the post on the edit action? -- Leonardo Mateo. There''s no place like ~ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Leonardo Mateo wrote:> On Sun, Jan 10, 2010 at 11:30 AM, Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> Hello, How can I do, when a user make a post, he only can edit his >> posts? >> > Check for the owner of the post on the edit action?Exactly, if you have an user on my website an post anything, you will edit or destroy only your posts. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/10 Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Leonardo Mateo wrote: >> On Sun, Jan 10, 2010 at 11:30 AM, Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> wrote: >>> Hello, How can I do, when a user make a post, he only can edit his >>> posts? >>> >> Check for the owner of the post on the edit action? > > Exactly, if you have an user on my website an post anything, you will > edit or destroy only your posts.I think that Leonardo meant that in the edit and destroy actions you should test that the current user is the owner of the post and not allow the action to proceed if not the owner. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> 2010/1/10 Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>: >> Leonardo Mateo wrote: >>> On Sun, Jan 10, 2010 at 11:30 AM, Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >>> wrote: >>>> Hello, How can I do, when a user make a post, he only can edit his >>>> posts? >>>> >>> Check for the owner of the post on the edit action? >> >> Exactly, if you have an user on my website an post anything, you will >> edit or destroy only your posts. > > I think that Leonardo meant that in the edit and destroy actions you > should test that the current user is the owner of the post and not > allow the action to proceed if not the owner. > > ColinAaahm.. I think yes. I don''t know another way to make it :S (I''m a little bit novice. I know a little bit Ruby but I get into mess with some things). I have thought to make a function current_user probing the user by name and make an if sentence : if post.name == current_user{ edit, destroy } For example, but I dont know how to make it exactly.. :S (I hear bells but i dont know where) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/10 Alberto Lopez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:>... > Aaahm.. I think yes. I don''t know another way to make it :S (I''m a > little bit novice. I know a little bit Ruby but I get into mess with > some things). I have thought to make a function current_user probing the > user by name and make an if sentence : if post.name == current_user{ > edit, destroy } > > For example, but I dont know how to make it exactly.. :S (I hear bells > but i dont know where)You need to be reasonably proficient in the use of Ruby to use RoR so I would suggest first googling for some Ruby primers and work through those. Then (or at the same time if you get bored) work through some of the online Rails Guides (google for Rails Guides), particularly Getting Started, ActiveRecord Relationships and Debugging. Another excellent way of learning is to watch this list and any time you understand the question then follow the thread and try to understand the answer. In no time you will find yourself answering questions yourself. You will make a fool of yourself on occasions (at least I did, and still do) but do not worry about that. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.