Ruby on Rails Sunday, September 2, 2012

On 1 September 2012 23:05, 7stud -- <lists@ruby-forum.com> wrote:
>> It's a feature of Rails. It's a problem if it causes problems.
>
> (Note: nothing in this post has anything to do with rspec.)
>
> For me, that routing behavior is causing problems. Here's why: if I add
> a route such as:
>
> get "static_pages/dog"
>
> ...and then enter the url http://localhost:3000/static_pages/dog in my
> browser, rails complains that there's no action called dog in the
> StaticPagesController:
>
> ===
> Unknown action
>
> The action 'dog' could not be found for StaticPagesController
> ===
>
> Then if I add the dog action to the controller, then create a view,
> everything works fine and dandy.
>
> But if I then delete the dog action, and then use the same url,
> http://localhost:3000/static_pages/dog, in my browser, this time I get a
> different result--instead of getting an error the view displays. For
> me, that inconsistent behavior is not right, and it should not be that
> way. So I want to know whether there were reasons for the rails team
> to institute that inconsistent behavior, or whether it is a bug.

It is not inconsistent. You started with no action and no view and
url fails. You added action and view and url works. You deleted only
the action and the view continues to work. If you delete the view
then it will fail again. Perfectly consistent. In fact the empty
action is just not needed. Rails assumes that since you have provided
a route and a view that you would like them to work and saves you the
effort of providing an empty action. I never intentionally rely on
that myself as I find it a little confusing, but it is not
inconsistent.

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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment