Routes with params

Hey all,

my code looks like:

<%= link_to ‘add’, :controller => ‘item’, :action => ‘add_me’, :title =>
posts.title, :description => posts.description %>

I already added

map.connect ‘:controller/:action’

to my routes.rb, but i always get:
No route matches “/item/add_me” with {:method=>:get}

Or should my link look something different?

Thanks for your help!



i strongly suggest you read about RESTful design and controllers in
Rails. You should find plenty of good tutorials on google.

I don’t know how you created the controller but it is usualy used in
plural. So if you create a model Item, the created controller is
called itemS_controller.rb. This means you should try accessing /items/
add_me (why add_me and not new?) rather than /item/add_me.

The line you wrote in the routes searches for any controller matching
first “parameter” in url and action second. I’m (almost) sure your
controller is in plural and this is the reason why the route doesn’t

But you should consider making a custom route like this:

map.items “items/:action”, :controller => “items”

Then in your views you can easily make links like this:

<%= link_to ‘All items’, items_path %>

Hope it helps! And hey… find and read some tutorials on restful

On 8 avg., 16:18, Stephan M. [email protected]

Hey, thanks for your reply.

I think i dont make clear what i want to do :slight_smile:

I try to add an item with custom params. I wrote my own action add_me
where i create an new item and filled it with this params (:title,

(Or should i call new and then update?)

The params comes from a loop over RSSReader posts, and add_me is to add
the rss content to my database.

greetings :slight_smile:

If you can, pick the book “The Rails Way” by Obie F… I just
read this exact chapter last night and explains is super good detail,
exactly what you are wanting/trying to do.

He explains custom routes, named routes, etc. very well - along with
it being an excellent book in many other areas.


On Aug 8, 10:18 am, Stephan M. [email protected]