Passing Variables to a Partial from a View – Ruby on Rails

Just another one of those things that I find myself needing to do from time to time. Luckily this is all pretty straight forward (thankyou Ruby on Rails!). Assuming your partial is a form in the locations folder and that the variable you’re expecting is location all that you have to do is following:

View: users/show.html.erb

 'locations/form', :locals => { :location => @user.location } %>

Partial: locations/_form.html.erb


Street: 

Good luck!


Posted

in

, ,

by

Comments

3 responses to “Passing Variables to a Partial from a View – Ruby on Rails”

  1. arss Avatar

    I think this is among the most vital info for me. And i am glad reading your article. But want to remark on few general things, The website style is perfect, the articles is really great : D. Good job, cheers

    Like

    1. Chris Avatar
      Chris

      Thanks for the feedback!

      Like

  2. Spring Mattress Avatar

    Glad to read this blog! Keep it going!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: