Forum: Ruby on Rails second table column data lift

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-07 02:42
(Received via mailing list)
have placements, clients and case_managers tables with relationships

Trying to create new placement record...case_manager_id field exists in
clients table. I need the value from related clients record in
placements table

in placements_controller.rb

def create
  @placement = Placment.new(params[:placement])
  case_manager_id = Client.case_manager_id  # this doesn't work
  if @placement.save
    flash[:notice] = 'Placement was successfully created'
    redirect_to :action => 'list'
  else
    render :action => 'new'
  end
end

How do I get the case_manager_id value from the related record since I
am already storing the client_id (the foreign key) because I need the
foreign key for case_manager_id or I cannot save?

Craig
This topic is locked and can not be replied to.