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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:05:09+00:00 2026-05-25T20:05:09+00:00

Environment: Rails 3.1.0, Ruby 1.9.2 I have Portfolio model which has_many Positions which has_one

  • 0

Environment: Rails 3.1.0, Ruby 1.9.2

I have Portfolio model which has_many Positions which has_one Asset.

This is the schema for the Position model:

create_table "positions", :force => true do |t|
    t.integer  "portfolio_id"
    t.integer  "asset_id"
    t.decimal  "holding_percentage"
end

When the user creates a portfolio he/she should enter the portfolio name and then add positions by adding stock tickers. Jquery does its stuff and shows the full name of the asset and also inserts the asset_id into the hidden field.

I am using both nested_form and simple_form as follows:

<%= simple_nested_form_for @portfolio  do |f| %>

    <%= f.input :name, :placeholder => 'Your portfolio name' %>  

    <%= f.fields_for :positions do |position_form| %>

        <%= text_field_tag 'asset-ticker', nil, :class => 'asset-ticker' %>         
        <span class="asset-name"></span>
        <%= position_form.text_field :holding_percentage, :class => 'asset-perc' %>
        <%= position_form.hidden_field :asset_id, :class => 'asset-num', :as => :hidden %>

        <%= position_form.link_to_remove "Remove this position", :class => 'asset-rem-link' %>
    <% end %>

    <p><%= f.link_to_add "Add a Position", :positions, :class => 'asset-add-link' %></p>  

    <%= f.button :submit %>

<% end %>

The problem is that the asset_id value in the hidden field is not being submitted. The parameters look as follows:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"hmvoGHF9GzpPsohQQ2MwhWk4FzhVVrf+IqoChHgftEs=",  
    "portfolio"=>{"name"=>"needhelpnow", 
                  "positions_attributes"=>
    {"new_1316730954406"=>{"holding_percentage"=>"11", "asset_id"=>"", "_destroy"=>"false"}, 
     "new_1316730961085"=>{"holding_percentage"=>"22", "asset_id"=>"", "_destroy"=>"false"}, 
     "new_1316730971587"=>{"holding_percentage"=>"33", "asset_id"=>"", "_destroy"=>"false"}}}, 
     "commit"=>"Create Portfolio"}
  • 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-25T20:05:10+00:00Added an answer on May 25, 2026 at 8:05 pm

    It turns out that the problem was that I was writing in the value of the hidden field with:

    ('.asset-num').html(data.id)
    

    Instead of:

    ('.asset-num').val(data.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have a mixed development environment using ASP.NET MVC and Ruby on Rails. We
I have a rails environment which I set-up with macports. I recently updated macports
Can anyone explain why this happens? mybox:$ ruby script/console Loading development environment (Rails 2.3.5)
I have a Rails 3 model D that belongs to another model, which belongs
Environment: Rails 3.0.4 and Ruby 1.9.2 I have the following form: <%= form_tag( {:action
I have a Ruby/Rails devvelopment environment using rbenv, MRI Ruby (1.9.2-p290), rails 3.0.9, and
I am learning and have already set up a Ruby on Rails environment based
First the environment: Rails 2.1.0, Ruby 1.8.7, Mysql 5.1.54, Ubuntu 11.04 I have a
I have installed RubyMine on Mac but my development environment for Ruby and Rails
My development environment: Ubuntu 9 Ruby 1.9.1/1.8.7 (rvm) Rails 2.3.5 Mysql 5.0 Apache Passenger

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.