Hello i have 5 fields from an invoice system (code,name,price,qty,total) i want when the user insert a code, the system automatically fill all the info from the DB into these columns. any ideas pleased? -- 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 -~----------~----~----~----~------~----~------~--~---
Edgar Ortiz wrote:> Hello i have 5 fields from an invoice system (code,name,price,qty,total) > i want when the user insert a code, the system automatically fill all > the info from the DB into these columns. > > any ideas pleased?A field observer on the code field. Then, in the controller, you retrieve the object from db and then update the page using rjs, like: render :update do |page| page[''name''].value=your_object.name page[''price''].value=your_object.price ... end Regards Massimo http://www.addsw.it -- 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 -~----------~----~----~----~------~----~------~--~---
Now i am confused with the observer, should look like this?
:item_codigo = field with the data i received
:update => ''articulos'' = is the div where is my field
get_X_code = mehod on my controller
<%= observe_field(:item_codigo,
:frequency => 0.5,
:update => ''articulos'',
:url => { :action => :get_X_code},
:with => "''codigo_id=''+escape(value)")%>
??
maner wrote:> Edgar Ortiz wrote:
>> Hello i have 5 fields from an invoice system
(code,name,price,qty,total)
>> i want when the user insert a code, the system automatically fill all
>> the info from the DB into these columns.
>>
>> any ideas pleased?
>
> A field observer on the code field.
> Then, in the controller, you retrieve the object from db and then update
> the page using rjs, like:
>
> render :update do |page|
> page[''name''].value=your_object.name
> page[''price''].value=your_object.price
> ...
> end
>
> Regards
> Massimo
> http://www.addsw.it
--
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
-~----------~----~----~----~------~----~------~--~---
how can i do the observer??? And when i pass the object to the .rjs template it return [object object] -- 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 -~----------~----~----~----~------~----~------~--~---
Edgar Ortiz wrote:> how can i do the observer??? > > And when i pass the object to the .rjs template it return [object > object]In your view: <%= observe_field(''item_codigo'', :url => { :action => :get_X_code}, :with => "codigo_id") %> No :update option is needed, since response is RJS In controller: item=Item.find_by_codigo_id(params[:codigo_id]) render :update do |page| page[''item_name''].value=item.name ... end -- 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 -~----------~----~----~----~------~----~------~--~---