Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7729147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:53:43+00:00 2026-06-01T05:53:43+00:00

i was wondering how to pass an object to a partial, and then again

  • 0

i was wondering how to pass an object to a partial, and then again to another partial?
im following the michael hartl book and this was an optional exercise but ive been super stuck.

if i have a..

<%= form_for(@user) do |f| %>
    <%= render 'fields', object: f.object %>

<% end %>

from the book, it said to use a hash with the value equal to the object and key equal to the name of the variable we want in the partial. so that means in the _fields.html.erb, the key ‘object’ should exist and it should have the value of f.object

<%= render 'shared/error_messages', object: ?????? %>

<%= object.label :name %>
<%= object.text_field :name %>

<%= object.label :email %>
<%= object.text_field :email %>

but when i try retrieving the key, i get an error on the line

<%= object.label :name %>

it says

undefined method `label' for #<User:0x007f86000110c0>

why does it throw that? i thought i could reference the key as ‘object’.

also, ive been stuck on what to replace the ?????? with. to replicate the error above, i took out the ?????? but it will throw another error from the next partial saying ‘object’ is undefined. i cant use something like f.object because f no longer exists. how can i get the value to pass onto the next partial?

thanks a lot = )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:53:44+00:00Added an answer on June 1, 2026 at 5:53 am

    Well, you’re passing in object: f.object, and f.object is a User. So then you try to call object.label, but User doesn’t have a label method. If you pass in object: f.object, f: f then in your partial you can call f.label.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc optimizes code when I pass it the -O2 flag, but I'm wondering how
I was wondering what the best way would be to pass a php object
Was wondering if it is recomended to pass a database connection object around(to other
Wondering if anyone can help me with this annoying but trivial (in terms of
So, I'm wondering how to pass parameters to a perl script from a .bat
I'm wondering if it's possibile to pass (any way is ok, also hacks) a
I am wondering if there is a way to pass a variable to a
I'm wondering the opinion of what is the best way to pass a lot
I'm wondering if there is a cleaner way to pass multiple variables in a
I'm wondering if someone could look over my code. I'm trying to pass a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.