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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:48:08+00:00 2026-05-23T17:48:08+00:00

I have a few shared partials that I can render from any controller fine

  • 0

I have a few shared partials that I can render from any controller fine however I am having a bit of trouble rendering form partials from another controller. I am wanting to be able to add notes to my contacts

In my contacts/show.html.erb i have the following

<% render :partial => "notes/form", :note => Note.new %>

In my notes/_form.html.erb i have the following

<%= form_for @note do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
  <p>
    <%= f.label :content %><br />
    <%= f.text_field :content %>
  </p>
  <p>
    <%= f.label :contact_id %><br />
    <%= f.number_field :contact_id %>
  </p>
  <p><%= f.submit %></p>
<% end %>

However I get the error:

Showing /Applications/Rails/apps/saas31/app/views/notes/_form.html.erb where line #1 raised:

undefined method `model_name’ for NilClass:Class

Extracted source (around line #1):

1: <%= form_for @note do |f| %>
2: <%= render ‘shared/error_messages’, :object => f.object %>

I’m starting to get the hang of rails but having a few small frustrating problems as to be expected when learning anything new i suppose. Anyone have any ideas?

  • 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-23T17:48:09+00:00Added an answer on May 23, 2026 at 5:48 pm

    Your local variables should be passed through in a locals hash.

    <% render :partial => "notes/form", :locals => {:note => Note.new} %>
    

    Read section 3.4.4 here.

    Your partial also shouldn’t use instance variables, change the following:

    <%= form_for @note do |f| %>
    

    to:

    <%= form_for note do |f| %>
    

    edit

    If you want to use an instance variable, you can do the following:

    <% render :partial => "notes/form", :locals => {:note => @note} %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few makefiles that store shared variables, such as CC=gcc , how
I have a few user controls that need to be shared between multiple Silverlight
I have a few VS 2010 C# projects that are shared between several solutions.
We have a few maven projects that inherit from eachother. Our persistence layer project's
I have a library that can be compiled as a shared library (or DLL
Over the last few months/years, I have shared a folder or two with numerous
I have a program that runs in a few threads. The main thread shares
I have a few related applications that I want to deploy to different computers.
I am trying to import one python script from another. I have a few
I have a few views which parse xml downloaded from the internet. The instruments

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.