To implement what you have asked for, one approach is:
1) In your Book model, define a named scope such as:
named_scope :viewable, :conditions=>"sold=1"
2) Then in your Books_controller add this method if it isn't there already:
def index
finder = Book.all
if current_user.guest?
finder = finder.viewable
end
hobo_index finder
end
you could also write the function this way(below), but, I find the top one
more readable
def index
finder = Book.all
finder = finder.viewable if current_user.guest?
hobo_index finder
end
On 8 February 2010 11:06, Dave Porter <[email protected]> wrote:
> Hi Tom,
>
> Brilliant Question, I have been struggling to do this sort of thing
> for ages - look forward to the replies...
>
> cheers Dave Porter - no relation :)
>
> On Feb 8, 10:09 am, tomPorter <[email protected]> wrote:
> > Example: Book model has 'sold' column defined as a boolean.
> >
> > How do I allow signed in users to see all records, but guests to only
> > see not sold books?
> >
> > Thanks!
> >
> > Tom P.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<hobousers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>
>
--
Venka Ashtakala, B.Eng, G.C. Eng
Venka Ashtakala & Associates
Software Development Consultants
Office: +1-703-596-0287
Fax: +1-815-550-1356
Mobile: +91 9886304317
[email protected]
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.