Pepe Sanchez wrote in post #1015368:
>

First of all, I think this:

<%= link_to 'New Ticket', new_ticket_path %>

should say:  new_tickets_path.  Note the plural form of tickets.  At 
least that is the way it is in Rails 3.09.   Head First Rails is an old 
enough book that it's probably not worth studying.  2008??!  That's a 
lifetime ago in computer programming, and rails changes faster than most 
things in the programming world.


> I understand now!
>
> To generate a link in my RoR application I just need to prefix the word
> "_path" with a controller name and it finds it.
>


That's not necessarily true.  You were on the right track to begin with. 
The second argument to the link_to method can be a path.  Rails will 
create some paths for you and assigns names to them, like 
new_tickets_path, which you can use as the second argument to link_to. 
Rails also automatically creates some methods you can use:

new_ticket_path(@ticket)

which creates the path to a page that shows a particular ticket.  But if 
one of those 'constants' or methods actually produces the path:

  '/some_page'

You could just specify that path directly yourself:

<%= link_to 'New Ticket', '/somepage' %>

As long as your routes file maps the path you specify as the second 
argument to link_to to one of your actions, it will work.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to