nifty-generators icon indicating copy to clipboard operation
nifty-generators copied to clipboard

Generating nifty scaffold on Rails3b3

Open greenplastik opened this issue 14 years ago • 18 comments

Ruby: 1.9.2dev Rails: 3.0b3

I've got nifty-generators added to my Gemfile. I successfully ran:

rails g nifty:layout

and:

rails g nifty:config

However when I tried to run:

rails g nifty:scaffold home

I got the following error: http://gist.github.com/381345

Thoughts?

greenplastik avatar Apr 27 '10 21:04 greenplastik

perhaps you should pass some attribute?

altamic avatar Apr 27 '10 22:04 altamic

In the Rails 2.3.x version of the nifty-generators scaffold command, you could specify just a controller name and it would create just the controller and the views.

The relevant part of the original help file for nifty_scaffold reads as follows:

script/generate nifty_scaffold post

    Will create a controller called "posts" it will contain all seven
    CRUD actions along with the views. A model will NOT be created,
    instead it will look for an existing model and use those attributes.

script/generate nifty_scaffold post name:string content:text index new edit

    Will create a Post model and migration file with the name and content
    attributes. It will also create a controller with index, new, create,
    edit, and update actions. Notice the create and update actions are
    added automatically with new and edit.

script/generate nifty_scaffold post ! show new

    Creates a posts controller (no model) with index, edit, update, and
    destroy actions.

I was hoping this would work the same way.

greenplastik avatar Apr 27 '10 23:04 greenplastik

Still looking for help on this.

greenplastik avatar Apr 30 '10 00:04 greenplastik

Still getting error on this. Thoughts?

greenplastik avatar May 09 '10 01:05 greenplastik

getting the same error using the following generator line: "rails g nifty:scaffold user_session --skip-model username:string password:string new destroy" Per Railscasts 160 Runs successfully without the --skip-model option Not sure if its a Thor bug or a Nifty one ruby 1.8.7 Rails 3.0.0.beta3

shaundrong avatar May 14 '10 23:05 shaundrong

same problem. rails 3.0.0b4 / ruby1.9.1

atipugin avatar Jun 14 '10 19:06 atipugin

keep getting same as here http://gist.github.com/381345 can't generate any nifty:scaffold in rails3betta3 app.

zaqwery avatar Jun 20 '10 19:06 zaqwery

solved. the problem was in the position of the attributes. Ryan suggests in screencast 160 using this line to generate a scaffold (in rails3beta3):

rails g nifty:scaffold user_session username:string password:string new destroy

that worked for me when I replaced attributes:

rails g nifty:scaffold user_session new destroy username:string password:string

zaqwery avatar Jun 20 '10 19:06 zaqwery

If I put the options first: rails g nifty:scaffold --skip-model --skip-migration --haml home index

then I get this: "No value provided for required arguments 'model_name'"

Actually I believe this is still open. I get the error when running (trying to just create controller & view): rails g nifty:scaffold home index --skip-model --skip-migration --haml

Ruby 1.8.7 Rails 3.0.0.b4

iamnader avatar Jul 08 '10 01:07 iamnader

Additionally, this fails when running rails destroy nifty:scaffold . Same error as listed above. It can be solved by reproducing the parameters passed to the generator in the first place, but I think in that condition, it shouldn't be necessary.

robyurkowski avatar Aug 31 '10 02:08 robyurkowski

See if this is fixed now in the latest commit.

ryanb avatar Sep 23 '10 22:09 ryanb

When running the command:

rails g nifty:scaffold home index --skip-model --skip-migration

I get the following error: http://gist.github.com/609116

Ruby 1.8.7 Rails 3.0.0

nwwatson avatar Oct 04 '10 01:10 nwwatson

@nickslime06, that's strange, it looks like a syntax error in the internal Rails route_set.rb file. I also don't see mention of nifty generators in the stack trace.

Do other built-in generators work such as rails g scaffold?

ryanb avatar Oct 13 '10 23:10 ryanb

Use:

rails g nifty:scaffold user_session username:string password:string new destroy --skip-model

Instead of:

rails g nifty:scaffold user_session --skip-model username:string password:string new destroy

And it worked.

plehoux avatar Oct 26 '10 21:10 plehoux

@plehoux, that is interesting. I wonder if there is any way I can resolve this. It seems like more of an issue with Thor, but if anyone has suggestions on how I can improve this let me know.

ryanb avatar Dec 28 '10 23:12 ryanb

I have also been working through this example and plehoux's example above worked for me too. However, I get an "invalid option: --skip-model" message. I noticed the last commend on this issue was a year ago but it is still in an open status.

rails g nifty:scaffold user_session username:string password:string new destroy --skip-model create app/controllers/user_sessions_controller.rb create app/helpers/user_sessions_helper.rb create app/views/user_sessions/new.html.erb route resources :user_sessions create test/functional/user_sessions_controller_test.rb /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:581:in block in process_args': invalid option: --skip-model (OptionParser::InvalidOption) from /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:innew' from /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:in process_args' from /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:591:inrun' from /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'

andrunix avatar Mar 03 '12 18:03 andrunix

Hi

I ran nifty:scaffold on rails 3.2.7 w/ruby 1.9.3 and it works fine. Use nifty-generators 0.4.6, but I am unable to get the layout to work still. trying to fix that. Surprisingly when I generated rails g nifty:scaffold welcome, it created welcomes, i'm wondering. Issue is around that somewhere I did wrong.

plus i did add config.autoload_paths += %W(#{config.root}/lib) to the application.rb under /config

btw. im new to this, so if someone could help would be brill.

mabbashm avatar Aug 08 '12 23:08 mabbashm

Check environment.rb, I am new to this but I was following a tutorial and placed config.gem 'authlogic' in environment.rb

That's what caused my problem. Once I removed it the nifty_scaffold worked as plehoux suggested.

wisamsalem avatar Dec 23 '12 13:12 wisamsalem