Passing objects?

Hello,

I was wondering if it was possible to pass objects between methods in
the controllers - or whether you can only pass strings??

example:

def method_one
@object = Model.find(params[:id)
redirect_to :action => “method_to”, :object => @object
end

def method_two
@object = params[:object]
end

The question is basically - can i access the object in method_two?
Or do i have to just pass the model id to method two and do another
query to find the model object?

Which is best practice?

Which is best practice?
Pass the model id and find it in the next action.

You could store the object in session (session[:object] = @object),
but generally it’s best to keep the session lightweight.

Steve

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