Denise Robinson
2007-Nov-13 20:07 UTC
Newbie - how to pass info from one screen to another
I know this is undoubtably a stupid question, but I beg your patience. I''m just getting started and I used to program mostly in VB. I have a company model/table and a quote model/table. When someone clicks Create New Quote while viewing a Company, I''d like to bring them to a new quote screen and then "set" the company name field on the new quote screen to the name from the company screen that they just left. Can someone explain how to do that? Thank you! -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Muller
2007-Nov-13 20:52 UTC
Re: Newbie - how to pass info from one screen to another
there are several ways to do this :) assuming, that the routes are set in your company view you simply add the company_id to the link <%= link_to "Quote", new_quote_path(:company_id => @company.id) %> in you quotes_controller: def new @company = Company.find[params[:company_id]) ... end and go in to you quote-view like: <h3><%= @company.name %></h3> -- 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 -~----------~----~----~----~------~----~------~--~---
Denise Robinson
2007-Nov-13 21:23 UTC
Re: Newbie - how to pass info from one screen to another
Thanks, Thorsten. When you say "assuming, that the routes are set" are you referring to "belong_to" type statements or do I need to do something with the config/routes file? And, in this link "<%= link_to "Quote", new_quote_path(:company_id => @company.id) %>" what is "new_quote_path"? -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Muller
2007-Nov-13 21:30 UTC
Re: Newbie - how to pass info from one screen to another
> When you say "assuming, that the routes are set" are you referring to > "belong_to" type statements or do I need to do something with the > config/routes file?yes, you must setup the routing, so that rails can find the right controller and action. something like: map.resources :companies map.resources :quotes> And, in this link "<%= link_to "Quote", new_quote_path(:company_id => > @company.id) %>" what is "new_quote_path"?new_quote_path generates a path/url for you, in this case to the new action in the quotes controller (and with the additional parameter company_id) that''s for so called RESTful routing -- 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 -~----------~----~----~----~------~----~------~--~---
Denise Robinson
2007-Nov-13 21:38 UTC
Re: Newbie - how to pass info from one screen to another
Thank you very much for clarifying. Will read up on the routing chapter ASAP. :) -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Muller
2007-Nov-13 21:50 UTC
Re: Newbie - how to pass info from one screen to another
Denise Robinson wrote:> Thank you very much for clarifying. Will read up on the routing chapter > ASAP. :)yep, do so. there are so many ways. have a look at nested routes. this would look like map.resources :companies do |company| company.resources :quotes end then you could use: new_company_quote_path(@company.id) with the same result (id in params[:company_id] ) as above for RESTful routes have a look at this: http://en.wikipedia.org/wiki/Representational_State_Transfer http://www.rubyrailways.com/great-ruby-on-rails-rest-resources/ -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 13, 2:07 pm, Denise Robinson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I know this is undoubtably a stupid question, but I beg your patience. > I''m just getting started and I used to program mostly in VB.Welcome to Rails :-) It can take a while to make the switch from Microsoft to Rails. Feel free to also use our forums that are setup especially for Microsoft developers making the switch: forum.softiesonrails.com. I''d also highly recommend a book like "Agile Web Development with Rails" (from pragprog.com, you could just get the pdf if you want) or "Ruby for Rails" by David A. Black. Both are really good for getting off the ground with Rails. Our blog also tends to focus on Microsoft-to-Rails topics from time to time. Hope this helps. Jeff softiesonrails.com essentialrails.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 -~----------~----~----~----~------~----~------~--~---
Denise Robinson
2007-Nov-14 14:02 UTC
Re: Newbie - how to pass info from one screen to another
> Welcome to Rails :-) It can take a while to make the switch from > Microsoft to Rails.I''m finding that. /rueful grin/> Feel free to also use our forums that are setup especially for > Microsoft developers making the switch: forum.softiesonrails.com.I will definitely check that out.> I''d also highly recommend a book like "Agile Web Development with > Rails" (from pragprog.com, you could just get the pdf if you want) or > "Ruby for Rails" by David A. Black. Both are really good for getting > off the ground with Rails.I started with Ruby on Rails by Patrick Lenz (which I read cover to cover) and then added Agile Web... (which I haven''t had time to read except to look up problems). I can get things happening if they''re in the same model, but I''m really stumbling when it comes to referencing things outside the model I''m currently working in. Perhaps the routing that Thorsten pointed out will help with that. I''m also struggling with simple things like building strings, so I added Ruby on Rails for Dummmies to my collection because it was so easy to find do''s and don''t for simple syntax. The other thing that''s really tripping me up is drop-down lists. Should be super easy, but I still don''t have a working one. Every book and code snippet has a little bit different syntax and none of them seem to work. Again, I''m trying to reference data in another model, so maybe it all comes back to that one issue. /shrug/ Just a bit frustrated right now... /sigh/ -- 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 -~----------~----~----~----~------~----~------~--~---