Ruby on Rails
Tuesday, September 12, 2017
I'm removing most of the "noise" from your output and focussing on the gallery-relevant bits:
On 2017-Sep-12, at 17:29 , Joe Guerra <JGuerra@jginfosys.com> wrote:here's the output of my routes... (sorry about the formatting)Prefix Verb URI Pattern Controller#Actiongallery_index GET /gallery(.:format) gallery#indexPOST /gallery(.:format) gallery#createnew_gallery GET /gallery/new(.:format) gallery#newedit_gallery GET /gallery/:id/edit(.:format) gallery#editgallery GET /gallery/:id(.:format) gallery#showPATCH /gallery/:id(.:format) gallery#updatePUT /gallery/:id(.:format) gallery#updateDELETE /gallery/:id(.:format) gallery#destroy
the key bit to notice is that the index route is "named" gallery_index because you used:
resources :gallery
and :gallery is the singular form
You very likely want to say instead:
resources :galleries
which will give you similar routes *except* from the index:
[ruby-2.4.1p111] //tmp $ cd example/
[ruby-2.4.1p111] tmp/example (master #%) $ rails g resources Gallery
Running via Spring preloader in process 61722
Could not find generator 'resources'. Maybe you meant 'resource', 'resource_route' or 'assets'
Run `rails generate --help` for more options.
[ruby-2.4.1p111] tmp/example (master #%) $ rails g resource Gallery
Running via Spring preloader in process 61823
invoke active_record
create db/migrate/20170912230824_create_galleries.rb
create app/models/gallery.rb
invoke test_unit
create test/models/gallery_test.rb
create test/fixtures/galleries.yml
invoke controller
create app/controllers/galleries_controller.rb
invoke erb
create app/views/galleries
invoke test_unit
create test/controllers/galleries_controller_test.rb
invoke helper
create app/helpers/galleries_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/galleries.coffee
invoke scss
create app/assets/stylesheets/galleries.scss
invoke resource_route
route resources :galleries
[ruby-2.4.1p111] tmp/example (master #%) $ cat config/routes.rb
Rails.application.routes.draw do
resources :galleries
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
[ruby-2.4.1p111] tmp/example (master #%) $ rails routes
Prefix Verb URI Pattern Controller#Action
galleries GET /galleries(.:format) galleries#index
POST /galleries(.:format) galleries#create
new_gallery GET /galleries/new(.:format) galleries#new
edit_gallery GET /galleries/:id/edit(.:format) galleries#edit
gallery GET /galleries/:id(.:format) galleries#show
PATCH /galleries/:id(.:format) galleries#update
PUT /galleries/:id(.:format) galleries#update
DELETE /galleries/:id(.:format) galleries#destroy
-Rob
On Tuesday, September 12, 2017 at 5:03:56 PM UTC-4, Colin Law wrote:On 12 September 2017 at 02:15, Joe Guerra <JGu...@jginfosys.com> wrote:
> ...
> I'm using... in my routes file.
>
> get resources :gallery
Why is the 'get' there?
Colin--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/af2a8305-0b83-4075-8b51-f0b610ac31a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment