Skip to content

Commit

Permalink
Set attr_accessible on the right attributes on User
Browse files Browse the repository at this point in the history
  • Loading branch information
Harold Giménez committed Oct 28, 2011
1 parent fcbe87c commit c3dd8ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/suspenders/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def set_active_record_whitelist_attributes
inject_into_class "config/application.rb", "Application", " config.active_record.whitelist_attributes = true\n"
end

def set_attr_accessibles_on_user
inject_into_file "app/models/user.rb",
" attr_accessible :email, :password\n",
:after => /include Clearance::User\n/
end

def migrate_database
rake "db:migrate"
end
Expand Down
14 changes: 13 additions & 1 deletion lib/suspenders/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def suspenders_customization
invoke :copy_miscellaneous_files
invoke :setup_root_route
invoke :set_active_record_whitelist_attributes
invoke :set_attr_accessibles_on_user
invoke :outro
end

Expand Down Expand Up @@ -103,12 +104,19 @@ def setup_root_route
end

def set_active_record_whitelist_attributes
if 'active_record' == options[:orm]
if using_active_record?
say "Setting up active_record.whitelist_attributes"
build(:set_active_record_whitelist_attributes)
end
end

def set_attr_accessibles_on_user
if using_active_record?
say "Setting up writable attributes on user"
build(:set_attr_accessibles_on_user)
end
end

def outro
say "Congratulations! You just pulled our suspenders."
say "Remember to run 'rails generate airbrake' with your API key."
Expand All @@ -119,6 +127,10 @@ def get_builder_class
Suspenders::AppBuilder
end

def using_active_record?
!options[:skip_active_record]
end

end
end

Expand Down

0 comments on commit c3dd8ab

Please sign in to comment.