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 7624547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:59:34+00:00 2026-05-31T04:59:34+00:00

Following Hartl’s railstutorial and I changed my error-messages partial to work with other objects

  • 0

Following Hartl’s railstutorial and I changed my error-messages partial to work with other objects http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec:edit_form.

After changing all my @user to object and passing :object => f.object when I render the partial, I get this error when I try to load up my sign up page:

NameError in Users#new: undefined local variable or method 'f'

and it points to this line

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

Any advice?

new.html.erb

<div id="mainlogo"><%= image_tag("sample_logo.png", :alt => "Sample Title", 
                                                    :class =>"round")%></div>

    <div id="errors_new">
    <%= render 'shared/error_messages', :object => f.object %>
    </div>

    <div id="signup_spacer"></div>

<div id="signupcontainer_new" class="round">
<h1>Sign Up</h1>
<p>It's free</p>

<div id="signupform_new">
    <%= render :partial => 'users/usersignup' %>
</div>

</div>

_error_messages.html.erb

<% if object.errors.any? %>
  <div id="error_explanation" class="round">


  <% object.errors.full_messages.each do |msg| %>
  <h2><%= msg %></h2>
     <% end %>


  </div>
<% end %>

_usersignup.html.erb

<%= form_for(@user) do |f| %>
  <div class="field">
    <%= f.label :username %><br />
    <%= f.text_field :name %>
  </div>
...
<% end %>
  • 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-05-31T04:59:35+00:00Added an answer on May 31, 2026 at 4:59 am

    f.object is only valid inside the block that defines f, which is now in the form partial.

    The line needs to be within the form_for block in the form partial as in the tutorial.

    The tutorial also creates a partial for just the fields, where that line can go.

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

Sidebar

Related Questions

I'm following Ruby on Rails Tutorial: Learn Rails by Example, by Michael Hartl. http://ruby.railstutorial.org/chapters/a-demo-app#sec:a_micropost_microtour
I am following Michael Hartl's Rails Tutorial Here: http://ruby.railstutorial.org/chapters/modeling-and-viewing-users-one#top I use this command to
I have been following this tutorial, http://ruby.railstutorial.org/chapters/modeling-users?version=3.2#top , and I tried this in the
I am following the Ruby on Rails tutorial by Michael Hartl http://ruby.railstutorial.org/ I installed
I am following Michael Hartl's Screencasts from railstutorial.org. According to chapter 5, I changed
Working through Michael Hartl's RailsTutorial and came across the following error - even though
I'm following the Rails Tutorial by Michael Hartl and I'm getting an unexpected error/failed
I am running Rails 3.0.1 and Rspec 2.0.1. I am following M. Hartl's Ruby
Following Hartl's RailTutorial for Rails(3.2). I keep getting this error message or oddly a
Following Hartl's Railstutorial on Chapter 10 where we protect user edit pages so that

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.