Variables in find

How can i make a variable in find my code is

@gardens = Garden.find(:all, :conditions => { :user_id => 1})

The number 1 must be a variable of user.id so you only get the stuff
placed by the user logged in at the moment

On 19 Oct 2007, at 09:04, GA Gorter wrote:

How can i make a variable in find my code is

@gardens = Garden.find(:all, :conditions => { :user_id => 1})

The number 1 must be a variable of user.id so you only get the stuff
placed by the user logged in at the moment

Not sure I get the question. What’s wrong with?
@gardens = Garden.find(:all, :conditions => { :user_id => user.id})

Ideally user would has_many :gardens, then you can just do
@gardens = user.gardens.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs