Re: [Rails] Re: Find object based on string value.
On 23 April 2012 21:13, Shandy Nantz <lists@ruby-forum.com> wrote:
> Even when I try something like:
>
> @obj = "#{params[:model]}".constantize
> @this = @obj.find(:first, :conditions => ["upper(#{params[:attr]}) = ?",
> params[:"#{params[:model].downcase}"][:"#{params[:attr]}"]])
>
> I still have a null object.
Why complicate things with the conditions when you are trying to get
the basic find going? What if you just do @obj.find :first
Look in development.log to see what query is being run.
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@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home