Problem passing parameters to a shared template from control

I am using a shared template from within another template AND also using
the
same from a controller action.
It works fine when called from the template BUT when called from the
controller the parameter is not passed in from the controller.

the controller action is -

def update
@picture = Picture.find(params[:id])
render(:template=>“shared/trip”, “image” => @picture)
end

and the shared template is - trip.rhtml

width="80" height="60" >

The template is invoked but the image variable within the template is
nil.

You have a nil object when you didn’t expect it!
The error occured while evaluating nil.file_name

Thanks

I tried further…

So it works if I set a attribute before calling from the controller
action.

def update
@picture = Picture.find(params[:id])
*@image = @picture

  • render :template=>“shared/trip”
    end

The problem now is that the same shared template is called from another
template

<%= render “shared/trip”, { “image”=>image_pp } %>

now inside trip.rhtm (the shared template) I have access to image by
@image
(attribute) if called from controller and by simple argument “image” (no
@) if called from another template.

Is there no way to pass a variable just like I do from a template?

Thanks in advance.

On 10/4/06, Nasir K. [email protected] wrote:

@picture = Picture.find(params[:id])

The template is invoked but the image variable within the template is nil.


You have a nil object when you didn’t expect it!
The error occured while evaluating nil.file_name

Thanks


I don’t like $_, actually the only place I like $s is in my wallet.

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