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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:26:47+00:00 2026-06-11T23:26:47+00:00

I am trying to allow a user to enter a project into a database.

  • 0

I am trying to allow a user to enter a project into a database. One of the fields allows them to enter multiple technologies for that project.

Here is my project controller, new and create action.

def new
  @project = Project.new
  @all_technols = Technol.all
  @project_technol = @project.projecttechnols.build

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @project }
  end
end

def create
  @project = Project.new(params[:project])
  params[:technols][:id].each do |technol|
    if !technol.empty?
      @project.projecttechnols.build(:technol_id => technol)
    end
  end
end

Here is my new project view for the multi select technology dropdown.

<%= fields_for(@project_technol) do |ab| %>
  <div class="tech">
    <%= ab.label "All Tech" %><br/>
    <%= collection_select(:technols, :id, @all_technols, :id, :tech, {}, {:multiple => true} ) %>
  </div>
<% end %>

project.rb

class Project < ActiveRecord::Base
  attr_accessible :tech
  has_many :projecttechnols
  has_many :technols, :through => :projecttechnols
end

technol.rb

class Technol < ActiveRecord::Base
  attr_accessible :tech
  has_many :projecttechnols
  has_many :projects, :through => :projecttechnols
end

projecttechnol.rb

class Projecttechnol < ActiveRecord::Base
  attr_accessible :project_id, :technol_id
  belongs_to :technol
  belongs_to :project
end

At the moment, I have a page where the user can enter a new technology. But I want to move this option to the create new project page, where they can either select existing technologies, or enter a new one, or do both, and they would save with that project.

When I try to save a new project however, I am getting this error.

Showing /home/james/Desktop/webapp/app/views/projects/new.html.erb where line #233 raised:

    undefined method `model_name' for NilClass:Class

Extracted source (around line #233):

233: <%= fields_for(@project_technol) do |ab| %>
234: 
235: <div class="tech">
236: <%= ab.label "All Tech" %><br/>

I am new to rails and still learning so please remember when answering. Thanks in advance.

EDIT

after changing

@project.projecttechnols.build(:technol_id => technol)

to

@project_technol = @project.projecttechnols.build(:technol_id => technol)

I now get this error:

NoMethodError in Projects#create

undefined method `map' for nil:NilClass

Extracted source (around line #240):

237: <div class="tech">
238: <%= ab.label "All Tech" %><br/>
239: 
240: <%= collection_select(:technols, :id, @all_technols, :id, :tech, {}, {:multiple => true} ) %>
241: </div>
242: <% end %>

EDIT 2

@all_technols = Technol.all in the create action

I now get this error.

NoMethodError in Projects#show

Showing /home/james/Desktop/webapp/app/views/projects/show.html.erb where line #181 raised:

undefined method `technol' for #<Project:0xb36823c>
Extracted source (around line #181):

178: <h3>Related books</h3>
179: 
180: <ul>
181:   <% @project.technol.each do |technol| %>
182:     <li><%= technol.tech %> <%= link_to "Details", technol_path(technol) %></li>
183:   <% end %>
184: </ul>
  • 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-11T23:26:48+00:00Added an answer on June 11, 2026 at 11:26 pm

    Your create action is rendering the new view again. However, @project_technol is not defined within the create action. The fields_for method calls model_name method on the argument passed in (@project_technol), but since @project_technol = nil, it’s throwing that error. To fix this, within your create action, change

    @project.projecttechnols.build(:technol_id => technol)
    

    to

    @project_technol = @project.projecttechnols.build(:technol_id => technol)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programming novice here. I'm trying to allow a user to enter their name, firstName
I am trying to allow users to enter Hebrew characters into certain fields in
So I'm trying to add some ability to my project to allow user-defined properties
I am trying to set up a page that will allow the user to
I'm trying to develop a Lync application that allows a user to select which
I am trying to create an asp.net web form that allows a user to
I'm trying to figure out how to allow a user to enter in a
I am desperately trying to use LinqKits PredicateBuilder to allow the user to enter
I'm implementing an autocomplete that will allow a user to enter in partial text
I am trying to create a user form that will allow the user to

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.