grimen / dry_scaffold Goto Github PK
View Code? Open in Web Editor NEWRails: A Rails scaffold generator that generates DRYer, cleaner, and more useful code. IMPORTANT: Not maintained anymore.
License: MIT License
Rails: A Rails scaffold generator that generates DRYer, cleaner, and more useful code. IMPORTANT: Not maintained anymore.
License: MIT License
Use collection_path, resource_path, etc. unless skipping inherited_resources.
Also, perhaps use the longer method for creating the form tag...
- semantic_form_for resource, :url => edit_resource_path(resource) do |form|
This will allow belongs_to/polymorphic controllers without any updates to the views.
The following command:
./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
Will generate the following in app/views/duck/index.html.haml
= "Resources" # I believe this was meant to say "Ducks"?
...
%th.name= 'Name'
%th.about= 'About'
%th.actions= 'Actions'
This makes i18n generation difficult. I suggest ussing human_name & human_attribute_name for the header & attributes, and t('Actions) for the Action header:
= Duck.human_name(:count => 2)
...
%th.name= Duck.human_attribute_name(:name)
%th.about= Duck.human_attribute_name(:about)
%th.actions= t('Actions')
Similarly, the links & buttons can be made i18n-compliant quite easily. The following lines:
= form.commit_button 'Create'
= link_to 'Show', resource_path(resource)
= will_paginate(@collection)
would become:
= form.commit_button t('Create')
= link_to t('Show'), resource_path(resource)
= will_paginate(@collection, :previous_label => t('Previous'), :next_label => t('Next') )
controller rspec code uses any_instance, but its not part of rspec
Contact José regarding the InheritedResources-issue:
parrot_url' /opt/local/lib/ruby/gems/1.8/gems/josevalim-inherited_resources-0.7.3/lib/inherited_resources/url_helpers.rb:194:in
resource_url'send' /opt/local/lib/ruby/gems/1.8/gems/josevalim-inherited_resources-0.7.3/lib/inherited_resources/base_helpers.rb:311:in
parse_redirect_url'create' /opt/local/lib/ruby/gems/1.8/gems/josevalim-inherited_resources-0.7.3/lib/inherited_resources/respond_to.rb:301:in
call'respond_any' /opt/local/lib/ruby/gems/1.8/gems/josevalim-inherited_resources-0.7.3/lib/inherited_resources/respond_to.rb:233:in
respond_to'respond_to_with_dual_blocks' /opt/local/lib/ruby/gems/1.8/gems/josevalim-inherited_resources-0.7.3/lib/inherited_resources/base.rb:78:in
create'process' /test/functional/donkeys_controller_test.rb:8:in
test_create'test 'create' do
Donkey.any_instance.expects(:save).returns(true)
@donkey = donkeys(:basic)
post :create, :donkey => @donkey.attributes # <<<<<<<<<<<<< donkeys_controller_test.rb:8
assert_response :redirect
end
test 'destroy with failure' do
Donkey.any_instance.expects(:destroy).returns(false)
@donkey = donkeys(:basic)
delete :destroy, :id => @donkey.to_param
assert_not_nil flash[:error] # <<<<<<<<<<<<< donkeys_controller_test.rb:45
assert_response :redirect
end
build_object reads 'factory_framework' but it is not set in scaffold.yml. in the yaml file, some other options are set 'true/false'
The line for the gem dependency in the documentation should be updated to:
config.gem 'formtastic', :source => 'http://gemcutter.org/'
my:
resourceful: false
shoulda: true
I've done this a couple times today to make sure - here's a gist:
If I pass it on the command line - it works just fine:
./script/generate dry_scaffold Zebra name:string about:text --skip-resourceful --shoulda
I may be doing something wrong - but I just want to:
create a rails app
add dry_scaffold
add a simple model/controller with your scaffold generator
have the basic tests pass
And I can't seem to be able to do that - like I said, I may be doing something wrong, but am not sure what.
Hi,
the generated scaffolds seem to be broken.
When generating a dry_scaffold wrong variable names are rendered in the views (using the default options).
Example:
ruby script/generate dry_scaffold Book ...
In index.html.haml the collection variable is referenced as @collection where it should be @books (as defined in the corresponding controller).
In new.html.haml, edit.html.haml and show.html.haml the instance variable is referenced as @resource where it should be @book
The titles in the views are also generated wrong: "New resource" "Editing resource..." etc. instead of "New book", etc. etc.
Come up with a smooth way to disable an option that is true by default, i.e. negative toggle.
This action:
./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
Generates "edit" links on the _item view.
Of course, if _actions isn't specified, it can be assumed that the default _actions are set.
Add option to generate RSpec-tests instead of Test::Unit/Shoulda.
The command I'm running is the line below. The line immediately following is the only response I get from the attempt. This is on an established project that has no other (apparent) issues.
generate dry_scaffold User name:string email:string
can't convert nil into String
I'm running Rails 2.3.5.
Get all combos of test templates to work, now way too many small typos/bugs.
There is no support of namespaces
Error:
Went away when I installed mocha:
sudo gem install mocha
Not sure if it's an issue with just my machine, but caused a bit of grief.
When I generate a dry_scaffold, run the migration, and go to the index page, I received the error
undefined method `total_pages'
Why does this happen?
Right now the following order generates errors (with all the dependencies installed):
./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
The errors are:
I believe the second error will also happen on edit - I just didn't generate a view for the action.
If I change @collection and @resource to @ducks and @duck the errors go away.
I generated 3 scaffolds and 2 models on the command line, specifying --fgirl for each one, yet a Factory was only generated for one of the five.
After experiencing some issues with the inherited_resources bits I decided to just skip them for now. But when I run "script/generate dry_scaffold Zebra name:string about:text --skip-resourceful" in my project the resourceful controller and views are still created.
:Fuzz
Hi!
This is a wonderful asset when creating apps and I use it al of the time. Curious, is there a Rails3 branch for this gem?
I know that Rails3 provides a new way of doing generators and templates where you could create something like this pretty easily. I do like the way you currently do it with dry_scaffold.
Thanks in advance,
Mark
Generator fails for some reason:
$ dscaffold ...
No such file or directory - /opt/local/lib/ruby/gems/1.8/gems/grimen-dry_scaffold-0.2.3/generators/dscaffold/../dry_scaffold/../../config/scaffold.yml
Add template generation for Shoulda-tests.
The old syntax:
should_redirect_to 'book_path(@book)'
The new syntax:
should_redirect_to("the book's show page") { book_path(@book) }
See http://dev.thoughtbot.com/shoulda/classes/Shoulda/ActionController/Macros.html#M000015
Write even better functional tests for REST-actions. Goal: Killer-tests, i.e. "best practice"-tests. Suggestion: Routing, formats, ...
Should be:
config.gem 'grimen-dry_scaffold', :lib => false
Setting 'fgirl' option to true in a config does not seem to work. Looking at code option should probably be 'factory_girl' but setting that to true does not work as expected either.
When generating a new scaffold the routes are not updated. I don't know if this is the intentional behaviour or not...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.