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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:36:00+00:00 2026-06-15T01:36:00+00:00

I have an app where a user can enter a project into a database.

  • 0

I have an app where a user can enter a project into a database.

There is an option where they can select a number of different technologies for their project. At the moment, the app flags up an error if the user doesn’t select at least 1 technology.

I am wanting to change this so that if they don’t select a technology, it automatically goes down as “other” instead.

Here is my project controller actions, new and create:

def new
    @project = Project.new
        @technol = Technol.new(params[:tech])

        @all_technols = Technol.order('tech ASC') 
        @all_technols = Technol.all
        tech_ids = params[:technols][:id].reject(&:blank?) unless params[:technols].nil?


        @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])
        @project.client = params[:new_client] unless params[:new_client].blank?
        @project.industry = params[:new_industry] unless params[:new_industry].blank?
        @project.business_div = params[:new_business_div] unless params[:new_business_div].blank?


if !params[:technols].nil?

            params[:technols][:id].each do |tech|


                if !tech.empty?

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

end

Here is the new view for the technology field

<ul> 


<% @all_technols.each do |technol| %> 



<li class="split"> 
<%= check_box_tag "project[technol_ids][]", technol.id,  @project.technols.include?(technol) %> 
<%= technol.tech %> 
</li> 

<% end %>
</ul> 

The technology ID for “other” in the technols table is “18”. So is there a way to say that if no technology is chosen, then :technol_id => ["18"].

I’m still new to rails, so please remember this when trying to help. Thanks very much

  • 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-15T01:36:01+00:00Added an answer on June 15, 2026 at 1:36 am

    You have two choices.

    First, add an hidden input to the form:

    <input type="hidden" name="project[technol_ids][]" value="18" />
    

    Second, update params in controller#action:

    def create
      ...
      technol_ids = params[:technol_ids].blank? ? [18] : params[:technol_ids]
      technol_ids.each do |id|
      ...
      end
      ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app where a user can enter a project into a database.
I have an app where a user can enter projects into a database. One
I have an app that allows users to enter a project into a database.
I have a textfield in my app, whre the user can enter any number
I have created edittexts in which user can enter numbers. In my app user
I am trying to allow a user to enter a project into a database.
In my iPhone app I have a settings page where a user can enter
I have an app where the user can create a new project and search
I have an android app, in which user can enter any xml source url
I have a small app, where user can make some calculations and solve equations.

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.