On 26 May 2011 17:06, John <[email protected]> wrote:
>
>
> On Thu, May 26, 2011 at 9:27 AM, Colin Law <[email protected]> wrote:
>>
>> On 26 May 2011 14:13, John <[email protected]> wrote:
>> >
>> >
>> > On Thu, May 26, 2011 at 8:43 AM, Walter Davis <[email protected]>
>> > wrote:
>> >>
>> >> Click isn't one of the REST states, so you will have to add that to
>> >> your
>> >> routes. In Rails 2.3, this looks like this:
>> >>
>> >> map.resources :posts, :member => { :click => :get }
>> >>
>> >> In Rails 3, you would do:
>> >>
>> >> resources :posts do
>> >>  member do
>> >>    get 'click'
>> >>  end
>> >> end
>> >
>> >         I have rails 3.0.7.Added a route as above but still line "<%=
>> > button_to "New", :action => "click" %>" generate the error .
>> >   "No route matches {:controller=>"posts", :action=>"click"}"
>>
>> That is the result of following advice without understanding that
>> advice.  The above syntax is explained in section 2.9.1 of the rails
>> guide on routing and expects an id to be passed, which is not what you
>> want.
>>
>> As has been stated several times you can use rake routes to see what
>> routes you have declared, and you will see that posts/click is not one
>> of them.
>
>      rake routes gave and following and it seems posts/click is there.
>       posts_index GET    /posts/index(.:format)     {:action=>"index",
> :controller=>"posts"}
>  click_post GET    /posts/:id/click(.:format) {:action=>"click",
> :controller=>"posts"}

Note that it has an id in there, as I said.

>       posts GET    /posts(.:format)           {:action=>"index",
> :controller=>"posts"}
>             POST   /posts(.:format)           {:action=>"create",
> :controller=>"posts"}
>    new_post GET    /posts/new(.:format)       {:action=>"new",
> :controller=>"posts"}
>   edit_post GET    /posts/:id/edit(.:format)  {:action=>"edit",
> :controller=>"posts"}
>        post GET    /posts/:id(.:format)       {:action=>"show",
> :controller=>"posts"}
>             PUT    /posts/:id(.:format)       {:action=>"update",
> :controller=>"posts"}
>             DELETE /posts/:id(.:format)       {:action=>"destroy",
> :controller=>"posts"}
>
>>
>> If you just want a static route (which I think you do) then have a
>> look at section 3.3
>
>        match ':posts/:click'         didn't work as per tutorial there.

Once again you have taken advice (in this case mine) without
understanding what is being suggested.  I should have directed you to
section 3.7.  If you had read and understood the guide you would have
seen this and not been led astray by my bad advice.

Colin

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

Reply via email to