Skip to content

Commit

Permalink
add attr_accessible line to scaffold models by default - closes ryanb#8
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Aug 15, 2009
1 parent eda2516 commit e585e76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.rdoc
Expand Up @@ -57,6 +57,11 @@ you can just change the templates to whatever approach you prefer for
setting the title.


<b>I can't set new attributes in my model.</b>

Add the attribute to the attr_accessible line in the model.


<b>I get "undefined method 'root_url'" error.</b>

Some generators default redirecting to the root_url. Set this in your
Expand All @@ -76,11 +81,6 @@ Try restarting your development server. Sometimes it doesn't detect the
change in the routing.


<b>I can't set new attributes in my User model.</b>

Add the attribute to the attr_accessible line in the model.


<b>The tests/specs don't work.</b>

Make sure you have mocha installed and require it in your spec/test helper.
Expand Down
1 change: 1 addition & 0 deletions rails_generators/nifty_scaffold/templates/model.rb
@@ -1,2 +1,3 @@
class <%= class_name %> < ActiveRecord::Base
attr_accessible <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>
end
3 changes: 2 additions & 1 deletion test/test_nifty_scaffold_generator.rb
Expand Up @@ -85,9 +85,10 @@ class TestNiftyScaffoldGenerator < Test::Unit::TestCase
end
end

should "generate model with class as camelcase name" do
should "generate model with class as camelcase name and add attr_accessible for attributes" do
assert_generated_file "app/models/line_item.rb" do |body|
assert_match "class LineItem < ActiveRecord::Base", body
assert_match "attr_accessible :name, :description", body
end
end
end
Expand Down

0 comments on commit e585e76

Please sign in to comment.