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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:20:54+00:00 2026-06-12T01:20:54+00:00

I have a page that allows users to create new projects. They have the

  • 0

I have a page that allows users to create new projects. They have the option to select from a drop down menu that is linked to a table colomn, incase the option they are looking for is already in the database, and another option where they can enter new data, that when the project is submitted, the new data for that filed gets saved into the database for the next person.

This is part of my new/edit project view:

<div class="client">
<%= label_tag :new_client, "Client" %><br/>
<%= text_field_tag :new_client, nil, :maxlength => 30 %>
Or
<%= f.select( :client, Project.all.map {|p| [p.client]}.uniq, :prompt => "Select a previous Client") %>
</div>

The user can either input new data via the text field, or select from the drop down. If the user puts new data in the text box AND selects something from the drop down, the new data is saved with the project as it takes priority.

My problem lies with the edit view:

When the user clicks the edit link, the project is shown with all of the data they put in, but all of it is held in drop down menus.

If they try to enter new data in to the textbox, and save the project, it gets saved with whatever is highlighted in the dropdown, and ignores the new data put into the text box.

The edit view is exactly the same as the new view.

Can anyone point me in the right direction. I am new to rails, so please remember this when trying to help.

Thanks in advance.

EDIT 4

    # GET /projects/1/edit
      def edit
        @project = Project.find(params[:id])
   end

      # POST /projects
      # POST /projects.json
      def create
        @all_technols = Technol.all
        @project = Project.new(params[:project])

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

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

    if !technol.empty?


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

    end
    end
        @project.client = params[:new_client] unless params[:new_client].blank?

        @project.project_owner = params[:new_project_owner] unless params[:new_project_owner].blank?
        @project.tech = params[:new_tech] unless params[:new_tech].blank?
        @project.role = params[:new_role] unless params[:new_role].blank?
        @project.industry = params[:new_industry] unless params[:new_industry].blank?
        @project.business_div = params[:new_business_div] unless params[:new_business_div].blank?

        respond_to do |format|
          if @project.save
            format.html { redirect_to @project, notice: 'Project was successfully created.' }
            format.json { render json: @project, status: :created, location: @project }
          else
            format.html { render action: "new" }
            format.json { render json: @project.errors, status: :unprocessable_entity }
          end
        end
      end

      # PUT /projects/1
      # PUT /projects/1.json
      # PUT /projects/1
  # PUT /projects/1.json
  def update
    @project = Project.find(params[:id])
    [:client, :project_owner, :tech, :role, :industry, :business_div].each do |attribute|
  params[attribute] = params["new_#{attribute}".to_sym] unless params["new_#{attribute}".to_sym].blank?
end

    respond_to do |format|
      if @project.update_attributes(params[:project])
        format.html { redirect_to @project, notice: 'Project was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      end
    end
  end

EDIT VIEW:

<h1>Editing project</h1>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<%= stylesheet_link_tag "form" %>


<%= form_for(@project) do |f| %>


  <% if @project.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>

      <ul>
      <% @project.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
<BODY LANG="en-GB" TEXT="#000000" DIR="LTR">
<P LANG="en-US" CLASS="western" ALIGN=RIGHT STYLE="margin-bottom: 0in">
<BR>
</P>
<P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
</P>

<div class ="padding">
</div>
<CENTER>
    <TABLE WIDTH=624 CELLPADDING=2 CELLSPACING=0 >
        <COL WIDTH=283>
        <COL WIDTH=20>
        <COL WIDTH=152>
        <COL WIDTH=138>
        <COL WIDTH=9>
        <THEAD>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=29 BGCOLOR="#999999" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H1 LANG="en-US" CLASS="western"><FONT COLOR="#003366"><FONT SIZE=4>
   <div id = "project_name">
<div class="project_name">
    <%= f.label :project_name %> : 
    <%= f.text_field :project_name,:maxlength => 30 %>
  </div>
</div>

</FONT></FONT></H1>
                </TD>
            </TR>
        </THEAD>
        <TBODY>
            <TR>
                <TD COLSPAN=2 WIDTH=307 HEIGHT=15 BGCOLOR="#e6e6e6" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H2 LANG="en-US" CLASS="western" ALIGN=LEFT>Database id:</H2>
                </TD>
                <TD COLSPAN=3 WIDTH=307 BGCOLOR="#e6e6e6" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H2 LANG="en-US" CLASS="western" ALIGN=LEFT>
   <div id ="smallbox">
<div id = "status">
  <div class="status"> 
    <%= f.label :status %> : 

    <%#= f.select :status, [['Active'],['Completed']], {:include_blank => true} %>
    <%= f.select :status, [['Active'],['Completed']] %>
  </div></div> 

</H2>
                </TD>
            </TR>
            <TR>

                <TD COLSPAN=5 WIDTH=618 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><B>

<div class="client">
<%= label_tag :new_client, "Client" %><br/>
<%= text_field_tag :new_client, nil,:maxlength => 30 %>
Or
<%= f.select( :client, Project.all.map {|p| [p.client]}.uniq, :prompt => "Select a previous Client") %>
</div>


</B>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
            </TR>
            <TR>
                <TD COLSPAN=2 WIDTH=307 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><B>
   <div class="business_div">
<%= label_tag :new_business_div, "Business Division" %><br/>
<%= text_field_tag :new_business_div, nil,:maxlength => 30%>
Or
<%= f.select( :business_div, Project.all.map {|p| [p.business_div]}.uniq, :prompt => "Select Business Division") %>
</div>
</B>
                    </P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
                <TD COLSPAN=3 WIDTH=307 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><B>
  <div class="project_owner">
<%= label_tag :new_project_owner, "Project Owner" %><br/>
<%= text_field_tag :new_project_owner, nil,:maxlength => 30 %>
Or
<%= f.select( :project_owner, Project.all.map {|p| [p.project_owner]}.uniq, :prompt => "Select a previous Project Owner") %>
</div>  

</B></P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
            </TR>

            <TR>
                <TD WIDTH=283 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
   <div class="start_date">
    <%= f.label :start_date %> : 
    <%= f.text_field :start_date, :class => 'datepicker', :style => 'width: 80px;' %>
  </div>  

</P>
                </TD>
                <TD COLSPAN=2 WIDTH=176 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
Entry Created by:<br> <%= @project.first_name %> <%= @project.last_name %>
  <%= f.hidden_field :first_name, :value => @project.first_name %>
<%= f.hidden_field :last_name, :value => @project.last_name %>
</P>
                </TD>
                <TD COLSPAN=2 WIDTH=151 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
   Entry date: <br>  <%= l DateTime.now.to_date %>

</P>
                </TD>
            </TR>
            <TR>
                <TD WIDTH=283 HEIGHT=13 VALIGN=TOP BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
   <div class="end_date">
    <%= f.label :end_date %> :
    <%= f.text_field :end_date, :class => 'datepicker', :style => 'width: 80px;' %>
  </div>  

</P>
                </TD>
                <TD COLSPAN=2 WIDTH=176 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">


Last Edited by: <br> <%= @project.edited_first_name %> <%= @project.edited_last_name %></P>

  <%= f.hidden_field :edited_first_name, :value => current_user.firstname %>
<%= f.hidden_field :edited_last_name, :value => current_user.lastname %>


                </TD>
                <TD COLSPAN=2 WIDTH=151 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
   Edited date:  <br> 

<% if !(@project.edited_date.blank?) %>


  <%= l @project.edited_date %>

<% end %>
 <%= f.hidden_field :edited_date, :value => DateTime.now.to_date %>
</P>
                </TD>
            </TR>
            <TR>
                <TD WIDTH=283 HEIGHT=13 VALIGN=TOP BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in">


<div class="tech">
<%= label_tag :new_tech, "Technologies Used :" %><br/>
<%= text_field_tag :new_tech, nil,:maxlength => 30 %>
Or
<%= f.select( :tech, Project.all.map {|p| [p.tech]}.uniq, :prompt => "Select a previous Technology") %>
</div>  

</P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
                <TD COLSPAN=2 WIDTH=176 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in">
   <div class="role">
<%= label_tag :new_role, "Role" %><br/>
<%= text_field_tag :new_role, nil,:maxlength => 30%>
Or
<%= f.select( :role, Project.all.map {|p| [p.role]}.uniq, :prompt => "Select a previous role") %>
</div>  

</P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
                <TD COLSPAN=2 WIDTH=151 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in">
   <div class="industry">
<%= label_tag :new_industry, "Industry:" %><br/>
<%= text_field_tag :new_industry, nil,:maxlength => 30%>
Or
<%= f.select( :industry, Project.all.map {|p| [p.industry]}.uniq, :prompt => "Select an industry") %>
</div>  

</P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
                    <P LANG="en-US" CLASS="western"><BR>
                    </P>
                </TD>
            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=15 BGCOLOR="#e6e6e6" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H2 LANG="en-US" CLASS="western">
   Summary Of Assignment:  

</H2>
                </TD>
            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">

                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>
<div class="summary">
    <%= f.label :summary %><br />
    <%= f.text_area :summary, :style => 'width: 500px;' 'height: 100px;' %>
  </div>

                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>


                </TD>
            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=15 BGCOLOR="#e6e6e6" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H2 LANG="en-US" CLASS="western">Additional Informaton</H2>
                </TD>
            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">


                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in">
   <div class="lessons_learned">
    <%= f.label :lessons_learned %><br />
    <%= f.text_area :lessons_learned, :style => 'width: 500px;' 'height: 100px;' %>
  </div>  

</P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>

                </TD>
            </TR>
            <TR VALIGN=TOP>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=67 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western">
   <div class="customer_benifits">
    <%= f.label :customer_benifits %><br />
    <%= f.text_area :customer_benifits,:style => 'width: 500px;' 'height: 100px;' %>
  </div>  

</P>
                </TD>

            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=13 BGCOLOR="#ffffff" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in">
   <div class="financials">
    <%= label_tag :financials, "Financial Responsibility:" %><br />
    <%= f.select :financials, [['£0 - £99,999'],['£100,000 - £249,999'],['£250,000 - £499,999 '],['£500,000 - £999,999 '],['£1,000,000 +']], :prompt => "Select" %>
  </div>
<P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>

<div class="keywords">
    Any other searchable keywords and tags?<br />
    <%= f.text_field :keywords %>
  </div>

</P>
                    <P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
                    </P>

                </TD>
            </TR>
            <TR>
                <TD COLSPAN=5 WIDTH=618 HEIGHT=14 BGCOLOR="#e6e6e6" STYLE="border: 1px solid #00000a; padding: 0.02in 0.06in">
                    <H2 LANG="en-US" CLASS="western"><A NAME="_GoBack"></A></H2>
                </TD>
            </TR>
        </TBODY>
    </TABLE>
</CENTER>
<P LANG="en-US" CLASS="western" STYLE="margin-bottom: 0in"><BR>
</P>
</BODY>
</HTML>


<div class="create_button">
<div class="actions">
    <%= f.submit "Save Edit", :class => "button", :confirm => "Are you sure you want to save the edit?" %>
  </div>
</div>




</div> <%#= small div %>





<% end %>






<%#= button_to 'Show', @project, :class => "button" %> 

<%#= button_to "Back", projects_path , :class => "button", :method => "get" %>
  • 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-12T01:20:56+00:00Added an answer on June 12, 2026 at 1:20 am

    This

    @project.client = params[:new_client] unless params[:new_client].blank?
    

    needs to be in the update method aswell.

    Update 2

    Also, when you call

    @project.update_attributes(params[:project])
    

    You overwrite @project with the contents of params[].
    So here’s one solution:

      # GET /projects/1/edit
      def edit
        @project = Project.find(params[:id])
      end
    
      # PUT /projects/1
      # PUT /projects/1.json
      def update
        @project = Project.find(params[:id])
        [:client, :project_owner, :tech, :role, :industry, :business_div].each do |attribute|
          params[:project][attribute] = params["new_#{attribute}".to_sym] unless params["new_#{attribute}".to_sym].blank?
        end
    
        respond_to do |format|
          if @project.update_attributes(params[:project])
            format.html { redirect_to @project, notice: 'Project was successfully updated.' }
            format.json { head :no_content }
          else
            format.html { render action: "edit" }
            format.json { render json: @project.errors, status: :unprocessable_entity }
          end
        end
      end
    

    Some tips: update_attributes also saves an object. See API Doc

    Also, this code is correct:

    params[:client] = params[:new_client] unless params[:new_client].blank?
    params[:project_owner] = params[:new_project_owner] unless params[:new_project_owner].blank?
    params[:tech] = params[:new_tech] unless params[:new_tech].blank?
    params[:role] = params[:new_role] unless params[:new_role].blank?
    params[:industry] = params[:new_industry] unless params[:new_industry].blank?
    params[:business_div] = params[:new_business_div] unless params[:new_business_div].blank?
    

    but this is shorter 😀

    [:client, :project_owner, :tech, :role, :industry, :business_div].each do |attribute|
      params[attribute] = params["new_#{attribute}".to_sym] unless params["new_#{attribute}".to_sym].blank?
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that allows users to create new projects. They have the
I have a page on my site that allows users to create a custom
I have a html page that allows users to submit a file. Below is
Trying to create a page that allows users to add edit and view a
I have a form which allows users to comment on a page, however they
I've created a page that allows users to download a file when they click
I'm creating simple payment form that allows users to select from several different gateways
I have a page that allows for used input, when the user inputs his/her
I have an ASP.NET (3.5) page that allows a user to upload an Excel
I have an online store. A products page that allows the user to view

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.