Not Able to create singleton resource #274

Closed
newdark opened this Issue May 5, 2013 · 3 comments

Comments

Projects
None yet
3 participants

newdark commented May 5, 2013

Was brought to my attention by this post Is there way to scaffold a singleton resource

I was trying to create a new resource that is called welcome however in Rails routes I or want to call welcome and not welcomes so I create

resource.welcome

This part works however when calling
rails g scaffold Welcome

you don't get the results expected which it generates

invoke active_record
create db/migrate/20111103072825_create_welcomes.rb
create app/models/welcome.rb
invoke rspec
create spec/models/welcome_spec.rb
route resources :welcomes
invoke scaffold_controller
create app/controllers/welcomes_controller.rb
invoke haml
create app/views/welcomes
create app/views/welcomes/index.html.haml
create app/views/welcomes/edit.html.haml
create app/views/welcomes/show.html.haml
create app/views/welcomes/new.html.haml
create app/views/welcomes/_form.html.haml
invoke rspec
create spec/controllers/welcomes_controller_spec.rb
create spec/views/welcomes/edit.html.haml_spec.rb
create spec/views/welcomes/new.html.haml_spec.rb
create spec/views/welcomes/show.html.haml_spec.rb
invoke helper
create spec/helpers/welcomes_helper_spec.rb
create spec/routing/welcomes_routing_spec.rb
invoke rspec
create spec/requests/welcomes_spec.rb
invoke helper
create app/helpers/welcomes_helper.rb
invoke rspec
invoke assets
invoke coffee
create app/assets/javascripts/welcomes.js.coffee
invoke scss
create app/assets/stylesheets/welcomes.css.scss
invoke scss
identical app/assets/stylesheets/scaffolds.css.scss

However the results I wanted was more like this

invoke active_record
create db/migrate/20111103072825_create_welcome.rb
create app/models/welcome.rb
invoke rspec
create spec/models/welcome_spec.rb
route resources :welcome
invoke scaffold_controller
create app/controllers/welcome_controller.rb
invoke haml
create app/views/welcome
create app/views/welcome/index.html.haml
create app/views/welcome/edit.html.haml
create app/views/welcome/show.html.haml
create app/views/welcome/new.html.haml
create app/views/welcome/_form.html.haml
invoke rspec
create spec/controllers/welcome_controller_spec.rb
create spec/views/welcome/edit.html.haml_spec.rb
create spec/views/welcome/new.html.haml_spec.rb
create spec/views/welcome/show.html.haml_spec.rb
invoke helper
create spec/helpers/welcome_helper_spec.rb
create spec/routing/welcome_routing_spec.rb
invoke rspec
create spec/requests/welcome_spec.rb
invoke helper
create app/helpers/welcome_helper.rb
invoke rspec
invoke assets
invoke coffee
create app/assets/javascripts/welcome.js.coffee
invoke scss
create app/assets/stylesheets/welcome.css.scss
invoke scss
identical app/assets/stylesheets/scaffolds.css.scss

I only bring this up because I feel like not using scaffolds because of this problem. I have about 1/4 instances where I need static pages/singular pages. Anyway please provide a solution if some one can.

newdark commented May 5, 2013

Wow I feel stupid after looking more into the code I found this flag. --singleton.

I am sorry for wasting every ones time.

@newdark newdark closed this May 5, 2013

naaano commented May 6, 2013

"welcome" doesn't look like a resource, looks like a single page, if i'm right you should use a GET instead

get '/welcome'

or so

So --singleton doesn't create a single record to manage. I would be very useful to manage some app settings managed by the user for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment