Why, in Ruby on Rails, http: // localhost: 3000 / stories / newnew will look for the id = newnew entry?

using Ruby on Rails 2.3.2 since I already created a Scaffold for the Story, so instead of experimenting and creating a new action called "new" ("new" already exists from the scaffold), I used "newnew" in the controller file and in the file kind, hoping that

http: // localhost: 3000 / stories / newnew

would be another way to create a new record. but it turns out that RoR will treat "newnew" as a record id instead of an action, as reported:

Could not find history with ID = newnew

Is there a way to make newnew also like an action?

route.rb has

map.resources :stories

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'

      

and this is Rails 2.3.2

-1


a source to share


3 answers


The source of the problem will probably be your route.rb, can you post its content in your question?



Depending on the version of the rails and the use of the RESTful resources, the behavior is different. In any case, route.rb should contain the response.

+2


a source


map.resources :stories, :collection => {:newnew => :get}

      

... will add a display newnew

to the collection of stories. This will know what it /stories/newnew

doesn't mean to reference the stories instance.



From here .

+2


a source


The default action is to list something with such a url. You can implement newnew in your story controller, but why?

0


a source







All Articles