What i want to do is allow only user created records to appear in the list and thus make them only able to edit their own. How would I do this? Many thanks, jakx12. -- 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 24 August 2010 16:37, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What i want to do is allow only user created records to appear in the > list and thus make them only able to edit their own. How would I do > this?Looking at the docs for ActiveScaffold I think you could use the conditions_for_collection method. However I would advise against using ActiveScaffold for the user part of a website. It is good for easy access to the database for development and admin purposes but for the ''real'' website I would recommend coding up what you really want rather than trying to push ActiveScaffold to the limit. Others may disagree with this. 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:> On 24 August 2010 16:37, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> What i want to do is allow only user created records to appear in the >> list and thus make them only able to edit their own. How would I do >> this? > > Looking at the docs for ActiveScaffold I think you could use the > conditions_for_collection method. However I would advise against > using ActiveScaffold for the user part of a website. It is good for > easy access to the database for development and admin purposes but for > the ''real'' website I would recommend coding up what you really want > rather than trying to push ActiveScaffold to the limit. Others may > disagree with this. > > ColinCan I just say, thank you sooo much for answering pretty much all my questions, and so fast! It is for the admin side of the site, just there are two levels of admin. So from what i can see i will be able to put in def conditions_for_collection end in the controller and place conditions in there that will change the find method into the database to give me all the stuff based on the conditions i give it in that action. How do i format the conditions though? 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 24 August 2010 21:59, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 24 August 2010 16:37, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> What i want to do is allow only user created records to appear in the >>> list and thus make them only able to edit their own. How would I do >>> this? >> >> Looking at the docs for ActiveScaffold I think you could use the >> conditions_for_collection method. However I would advise against >> using ActiveScaffold for the user part of a website. It is good for >> easy access to the database for development and admin purposes but for >> the ''real'' website I would recommend coding up what you really want >> rather than trying to push ActiveScaffold to the limit. Others may >> disagree with this. >> >> Colin > > Can I just say, thank you sooo much for answering pretty much all my > questions, and so fast! It is for the admin side of the site, just there > are two levels of admin. So from what i can see i will be able to put in > def conditions_for_collection > > end > in the controller and place conditions in there that will change the > find method into the database to give me all the stuff based on the > conditions i give it in that action. How do i format the conditions > though?1. First work out what the conditions are - in detail that is. 2. Then work out how to enter them. Do you know the answer to 1? 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 24 August 2010 21:59, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> the ''real'' website I would recommend coding up what you really want >> �end >> in the controller and place conditions in there that will change the >> find method into the database to give me all the stuff based on the >> conditions i give it in that action. How do i format the conditions >> though? > > 1. First work out what the conditions are - in detail that is. > 2. Then work out how to enter them. > > Do you know the answer to 1? > > ColinYup, the list will only be allowed have records that have a created_by value that is equal to the logged in users name, which is current_user.name -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bump.. -- 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.
Colin Law
2010-Aug-25 07:33 UTC
Re: Re: Re: How to have to a filter in activescaffold list
On 24 August 2010 22:21, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 24 August 2010 21:59, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> the ''real'' website I would recommend coding up what you really want >>> �end >>> in the controller and place conditions in there that will change the >>> find method into the database to give me all the stuff based on the >>> conditions i give it in that action. How do i format the conditions >>> though? >> >> 1. First work out what the conditions are - in detail that is. >> 2. Then work out how to enter them. >> >> Do you know the answer to 1? >> >> Colin > > Yup, the list will only be allowed have records that have a created_by > value that is equal to the logged in users name, which is > current_user.nameAre you sure? If you store the users name in created_by then if the user changes his name you will lose the link. It would be more usual to have YourModel belongs_to user and User has_many your_models. However if that is what you want: If you are having difficulty understanding the docs then google is often very useful. I did a google search on activescaffold conditions_for_collection and this example and [1] came out top of the list. It seems pretty easy. something like def conditions_for_collection "created_by = #{current_user.name}" end would seem to be a likely first try. [1] http://wiki.activescaffold.com/wiki/published/Dynamic+conditions_for_collection By the way I see that you have bumped this while I have been typing. There is no point bumping so quickly, one has to sleep you know. 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Zack Nathan
2010-Aug-25 10:31 UTC
Re: Re: Re: How to have to a filter in activescaffold list
sorry :s, im just working with a deadline. Its a website for my local gym (needs to be done by friday) and so the names will not change. I did a google aswell, but I couldnt seem to find that, thanks though! -- 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.