nifty-generators
nifty-generators copied to clipboard
Generating nifty scaffold on Rails3b3
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?
perhaps you should pass some attribute?
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.
Still looking for help on this.
Still getting error on this. Thoughts?
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
same problem. rails 3.0.0b4 / ruby1.9.1
keep getting same as here http://gist.github.com/381345 can't generate any nifty:scaffold in rails3betta3 app.
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
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
Additionally, this fails when running rails destroy nifty:scaffold
See if this is fixed now in the latest commit.
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
@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
?
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, 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.
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:in
new'
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:in
run'
from /Users/andrunix/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'
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.
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.