I have this code in my view:
<%= text_field_with_auto_complete :client, :name %>
when I submit new, y get:
"client"=>{"name"=>"MSO"}
I want to get:
"repair_ticket"=>{"client_id"=>"??"}
My models are
class Client < ActiveRecord::Base
has_many :repair_tickets
end
class RepairTicket < ActiveRecord::Base
belongs_to :client
end
How can I do that?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I''m not sure what you''re asking but here goes.
They submit :client => {:name => ''john''}
you do
client = Client.find(:first, :include => [:repair_tickets] :conditions
=> [''name = ?'', params[:client][:name]])
client.repair_tickets => what you want?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
John Smith wrote:> I have this code in my view: > > <%= text_field_with_auto_complete :client, :name %> > > when I submit new, y get: > "client"=>{"name"=>"MSO"} > > I want to get: > "repair_ticket"=>{"client_id"=>"??"}A bit of a hack, but you could do somthing like this before you save: @repair_ticket.client_id = params[''form_field''][''name''] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---