Restful Link_to

Bolo, I believe you have your attributes wrong. Try this:

<%= link_to 'rate it', vote_url(:id => @faq.id, :score => 1), :post => true %>

I am concerned about your faq.id being sent as the id... shouldn't it
be :faq_id => @faq.id if you are trying to create a new vote object?

hello Carl,

try your code
<%= link_to 'rate it', vote_url(:faq_id => @faq.id, :score => 1), :post
=> true %>

This link redirect me here (show method and not create method)
http://localhost:3000/votes/41?faq_id=41&score=1
:frowning:

Bolo, I don’t know why you are continuing to use post. It’s not the right method.

Stuart

Did it redirect you? IE It created your vote and then redirected you
to show? Or did it just send you to show?

Please post the entire contents of the link tag. Also, what is the
correct URL you are aim for?

Stuart,

He is trying to CREATE something, so POST is definitely the way to go.
You don't want votes to be created by some web crawler or some crazy
Google Caching tool do you?

The URL that is generated by the link_to has the params in the URL but
I it is not working for some reason.

Carl

Thanks Carl, I was going by the list of the 7 methods / routes. I guess I’m wrong.
Stuart

Ok, I just asked Rick Olson (core member) and he said this won't
work/isn't supported. Primarily because it isn't really 'RESTful'. But
that doesn't mean you can't go old school on it and do it that way. So
create an add_vote method and grab the params and go on about your
day. But still use the :post => true for the reasons I explained to
Stuart.

Stuart... I don't think you were wrong at all. If you are trying to
get to the form to enter data (which is 'new'), then you are correct.
However, if you are trying to actually create the object from the
link, then you would want to go this other route. Who knows what Mr.
Bolo wants :slight_smile:

Thanks Carl! I’m far from a rest initiate, even though I took the plunge to make my app as restful as possible.
Good to know about the link , sure at some point I’ll need it :slight_smile:

Stuart

Yeh boys

1. i am girl :slight_smile:
2. i would like a create a object form link

Ok, I just asked Rick Olson (core member) and he said this won't
work/isn't supported. Primarily because it isn't really 'RESTful'. But
that doesn't mean you can't go old school on it and do it that way. So
create an add_vote method and grab the params and go on about your
day. But still use the :post => true for the reasons I explained to
Stuart.

Okidoki Thanks

If you take the old school route you will be allowing delete operation by manipulating the URL
right?

Bala,

No. By 'old school' I mean that you create a method that has very
specific functionality and does not directly map to CRUD.

Carl