# Newbie - how to pass info from one screen to another

**URL:** <https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112>\
**Category:** Rails\
**Created:** [November 13, 2007, 9:07pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112 "2007-11-13T21:07:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 9:07pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/1 "2007-11-13T21:07:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 9:52pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/2 "2007-11-13T21:52:33Z")

</div>

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:

### \<%= @company.name %\>

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 10:23pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/3 "2007-11-13T22:23:27Z")

</div>

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”?

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 10:30pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/4 "2007-11-13T22:30:24Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 10:38pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/5 "2007-11-13T22:38:59Z")

</div>

Thank you very much for clarifying. Will read up on the routing chapter  
ASAP. 🙂

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/6 "2007-11-13T22:50:54Z")

</div>

Denise R. 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:

> **[Representational state transfer](https://en.wikipedia.org/wiki/Representational_State_Transfer)**
>
> Representational state transfer (REST) is a software architectural style that was created to guide the design and development of the architecture for the World Wide Web. REST defines a set of constraints for how the architecture of an Internet-scale distributed hypermedia system, such as the Web, should behave. The REST architectural style emphasises the scalability of interactions between components, uniform interfaces, independent deployment of components, and the creation of a layered architec...

[http://www.rubyrailways.com/great-ruby-on-rails-rest-resources/](http://www.rubyrailways.com/great-ruby-on-rails-rest-resources/)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 14, 2007, 3:02pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/7 "2007-11-14T15:02:55Z")

</div>

> 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](http://forum.softiesonrails.com).

I will definitely check that out.

> I’d also highly recommend a book like “Agile Web D. with  
> Rails” (from [pragprog.com](http://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/

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [November 13, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/newbie-how-to-pass-info-from-one-screen-to-another/120112/8 "2007-11-13T23:12:25Z")

</div>

On Nov 13, 2:07 pm, Denise R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](http://forum.softiesonrails.com).

I’d also highly recommend a book like “Agile Web D. with  
Rails” (from [pragprog.com](http://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

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

[essentialrails.com](http://essentialrails.com)
