Hi --
On Wed, 21 Jan 2009, Mohammad Abed wrote:
> That is not necessary, Now I get the same error for the first if clause
> (when the param is null, and I just type "mysite.com/galleries", the
> other two clauses work ok. This what my code looks like
>
> if params[:user_id].blank?
> @galleries = Gallery.find(:all, :conditions => ['visibility_status =
> ?', true])
I'm not sure how that if clause can give a "called id on nil" error,
since it doesn't call id. Can you examine the stacktrace and see if
you can pinpoint it?
Also, though I know this isn't your question, I'd advise putting all
of this logic in the model(s). For example:
class User < AR::Base
has_many :galleries
has_many :visible_galleries,
:class_name => "Gallery",
:conditions => ["visibility_status = ?", true]
Then you can do:
@galleries = user.visible_galleries
or something like that, in the controller, instead of in-lining the
business logic of the model.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)
http://www.wishsight.com => Independent, social wishlist management!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---