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

  • Home
  • SEARCH
  • 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 427213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:33:26+00:00 2026-05-12T19:33:26+00:00

I am using Single Table Inheritance for managing different types of projects. Models: class

  • 0

I am using Single Table Inheritance for managing different types of projects.

Models:

class Project < ActiveRecord::Base
end

class SiteDesign < Project
end

class TechDesign < Project
end

Edit action from projects_controller:

def edit
   @project = Project.find(params[:id])
end

View edit.html.erb:

<% form_for(@project, :url => {:controller => "projects",:action => "update"}) do |f| %>
    ...
    <%= submit_tag 'Update' %>
<% end %>

Update action of projects_controller:

def update
    @project = Project.find(params[:id])
    respond_to do |format|
      if @project.update_attributes(params[:project])
        @project.type = params[:project][:type]
        @project.save
        flash[:notice] = 'Project was successfully updated.'
        format.html { redirect_to(@project) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @project.errors, :status => :unprocessable_entity }
      end
    end
  end

Then i do some edits of TechDesign entry on edit view and get error:

NoMethodError in ProjectsController#update

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

In parametrs it is obvious that instead of project parameter name i have tech_design
Parameters:

{"commit"=>"Update",
 "_method"=>"put",
 "authenticity_token"=>"pd9Mf7VBw+dv9MGWphe6BYwGDRJHEJ1x0RrG9hzirs8=",
 "id"=>"15",
 "tech_design"=>{"name"=>"ech",
 "concept"=>"efds",
 "type"=>"TechDesign",
 "client_id"=>"41",
 "description"=>"tech"}}

How to fix it?

  • 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-12T19:33:27+00:00Added an answer on May 12, 2026 at 7:33 pm

    Here’s the source of your problem. This is setting @project as an instance of a TechDesign object.

    def edit
       @project = Project.find(params[:id])
    end
    

    You can ensure things work the way you want by specifying :project for a name in the form_for call.

    <% form_for(:project, @project, :url => {:controller => "projects",:action => "update"}) do |f| %>
        ...
        <%= submit_tag 'Update' %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 493k
  • Answers 493k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you're not really following the best practices of developing a… May 16, 2026 at 10:42 am
  • Editorial Team
    Editorial Team added an answer In your application.ini you can do this: oauth_consumer.callbackUrl = "http://www.domain.com/twitter/callback"… May 16, 2026 at 10:42 am
  • Editorial Team
    Editorial Team added an answer ... WHERE DATE(field)=CURDATE() or ... WHERE DATE(field)=CURRENT_DATE or ... WHERE… May 16, 2026 at 10:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am using Single Table Inheritance for managing different types of projects. I decided
I am using Single-Table Inheritance (STI) on one of my models for a Rails
When using single table inheritance does one have to be careful not to populate
I am using single table inheritance in my rails application, and want to explicitly
I am using Single Table Inheritance and have comments on all the subclasses. I
I'm using single table inheritance for my application. My polymorphic type is Maintenance with
I have two types of classes: BaseUser < ActiveRecord::Base and User < BaseUser which
I have a table entity called position. I am storing the value using smallint(2)
How to return a select result with batches through a single query, that should
I have a need to monitor a subset of fields on a table and

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.