On 29 June 2010 03:36, RailsFan Radha <[email protected]> wrote: > > This is "show" action in my "category controller". > > #---- Show --- > def show > # @category=Category.find(params[:category_id]) > @category=Category.find(params[:category_id]) > end > > "show" action - restrict manual url change from user to view the > inactive records. " > Active/inactive are set via status column in category table. > where status='A' > > since the url shows up in the url bar, the user can simply type in a > different category_id and view the record, even if status = 'I' > but, i don't want the user to modify the url and view the category where > status <> 'A' > In short, the users get to view only status='A' > > How do i do this for show action? (since this accepts a param) > I made the change for list action and list is working fine and shows > only where status='A'. List doesn't accept any params such as > "category_id" so it was ok. > > but this show accepts a param which is category_id. > > let me know how i could get the result of showing only actives and none > other statuses, directly from the url or via show action.
Add a condition to the find call so that it only finds active categories. If the id does not match a valid category then it will return nil. Colin > > thanks, > radha. > > (i have tried by best to communicate.. but let me know if any is not > clear. i will re-iterate) > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

