On Feb 8, 2010, at 2:30 AM, Venka Ashtakala wrote:

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


There must be a typo someplace in one of the guides, as I've seen people having trouble with this before: the .all above is not required (and will, in fact, break pagination). Another way to write the above would be:

def index
  if current_user.guest?
    hobo_index :scope => :viewable
  else
    hobo_index
  end
end

--Matt Jones

--
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.

Reply via email to