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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:11:13+00:00 2026-05-23T14:11:13+00:00

the problem I’m having is company_id is not been save to the details table

  • 0

the problem I’m having is company_id is not been save to the details table
I know the company_id is there I check it using <%= debug(params[:id])%> on the form before adding all company details information but for some reason is saving everything else but the company_id


##user.rb
has_one :company

##company.rb
belongs_to :user
has_one :detail

##detail.rb
belongs_to :user

##details controller
 def new
    @detail = Detail.new
    user_id = session[:user_id]
    company_id = params[:id]

  end

  def create     
    @detail = Detail.new(params[:detail])
    @detail.user_id = session[:user_id]
    @detail.company_id = params[:id]
  end

###settings.html.erb
### this is where i make sure that company_id gets pass with the url

  link_to 'New Detail', {:controller => 'details', :action =>'new', :id => company.id }, :class => 'plus'

#####routes
    resources :details
    resources :companies
    resources :users
    resources :sessions

I know this may not look pretty or proper if you know a better way please let me know…thanks in advance.

  • 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-23T14:11:14+00:00Added an answer on May 23, 2026 at 2:11 pm

    I didn’t realize this until later but I need it pass values to from on the view to the from like so

      <% @companies.each do |company| %>
          <%= link_to 'New Detail', {:controller =>'details', :action => 'new', :company_id => company.id},  :class => 'plus' %>
        <% end %>
    

    and I need it to collect that value on the from…like so

    <%= form_for(:detail, :url =>{:action => 'create', :company_id => @company.id}) do |f| %>
    ...(values)
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: detectLocationtimersset() logic does not seem to work. I know the sub routine is
Problem description is follows: There are n events for particular day d having start
Problem: Been struggling to get my code to load external shaders and it is
Problem: I have a table that prints out vertical but I would like it
Problem: I am trying to build a recursive tree using a function and data
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Problem Using Director 11.5 and Windows 7, with MouseWheel Xtra (wheelmouse.zip), I have the
Problem occured when i tried to display xml data that has been taken by
Problem I need to construct a 2D grid using a set of candidate positions
[Problem] There is a website which works for US-citizens only (shows info A for

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.