Rails - Any way to pass state to a component?

D

deja

I am trying set up a rails app that utilizes components. I need to be
able to pass some state (a bunch of name value pairs) from the Main
controller to the component.

Is there any way to pass this state info using render_component?

Regards
 
M

m4dc4p

Check the docs, but I believe you can pass a hash called :params with
any name-value pairs you need. They then show up in the @params
instance variable in the components controller:

render_component :controller => "foo", :action => "bar", :params => {
:baz => "bil" }
....
class FooController
....
def bar
@baz = @params[:baz] # "bil"
...
end

HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top