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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:09:46+00:00 2026-05-24T17:09:46+00:00

I have the following form partial (contacts/_form.html.erb) <%= semantic_form_for [@contact.user, @contact], :remote => true

  • 0

I have the following form partial (contacts/_form.html.erb)

<%= semantic_form_for [@contact.user, @contact], :remote => true do |f| %>
<% f.inputs do %>
    <%= f.input :firstname, :label => 'First Name' %>
    <%= f.input :lastname, :label => 'Last Name' %>
    <%= f.input :email, :label => 'Email' %>

    <%= f.input :groups, :collection => @user.groups, :as => :check_boxes, :label => 'Groups' %>

    <%= f.input :notes, :input_html => { :class => 'autogrow', :rows => 10, :cols => 50, :maxlength => 10  }, :label => 'Notes' %>
<% end %>


<%= f.buttons do %>
    <% if ["edit", "update"].include? params[:action] %>
        <%= button_submit_tag raw("Update Contact &rarr;") %>
    <% else %>
        <%= button_submit_tag raw("Create Contact &rarr;") %>
    <% end %>
<% end %>

<% end %>

I am trying to render it from contacts/index.html.erb

<%= render :partial => 'form'%>

But i get the error…

undefined method `user' for nil:NilClass
  • 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-24T17:09:48+00:00Added an answer on May 24, 2026 at 5:09 pm

    What was happening was a stupid mistake.

    I was having CANCAN load and authorize the resource, then i was specifying the @contacts = whatever for my index view, and it was screwing cancan up and it wasn’t auto generating the instance variables for that action anymore.

    Either way the fix was writing it out instead of letting cancan auto-generate it…

    @user = User.find(params[:user_id])
    @contact = @user.contacts.build
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form with Formtastic: = semantic_form_for @user, :url=> url_for(register_path), :html =>
I have the following code: tasks/_form.html.haml %h3 Tasks %span.form-inline.centered = form_for [@activity, @task], remote:
I have the following in my form <td><input id=Notifications_0__IssueCreate name=Notifications[0].IssueCreate type=checkbox value=true /><input name=Notifications[0].IssueCreate
I have a form for creating an album like following: # app/views/albums/new.html.erb <h2>Details of
I have the following form: @model Teesa.Models.SearchModel @using (Html.BeginForm(Index, Search, FormMethod.Get, new { id
I have the following form: echo $this->Form->input('Person.name'); echo $this->Form->input('Person.phone'); echo $this->Form->input('Person.email'); echo $this->Form->input('Message.0.plainmsg'); echo
I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I have following simple code: <%@ Page Language=C# AutoEventWireup=true CodeBehind=testForm.aspx.cs Inherits=Orbs.testForm %> <html> <body>
I have the following: public partial class Form1 : Form { public Form1() {
I have the following block of Razor markup: @section StoreSearch { @Html.Partial(SearchPartial, Model) }

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.