Rake migration aborted
I'm running Ruby 2.0.0 and I installed it correctly. Just loaded up a gem 'devise' and as I tried to migrate my database changes, it wouldn't work:
$ rake db:migrate rake aborted! attr_accessible
is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes
to your Gemfile to use old one.
Then, following another Stackoverflow post, they recommended installing Bundler. I did that successfully and got this:
$ bundle exec rake db:migrate rake aborted! attr_accessible
is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes
to your Gemfile to use old one.
Is anyone up to the challenge to help?
It looks like you are trying to use Rails 4.0.0beta which is not (IMHO) the best choice for a newbie. You'd better switch back to Rails 3* and yield all the advantages of well-documented, tested rock-n-rolling environment. If you still decide to stick to Rails 4… Previously there were no strict rules to deal with mass-assignment. Rails 4 standardises this with Strong Parameters , which has been merged into rails core. Thus, you are to do smth like:
# controllers/my_controller.rb
def create
@app = MyApp.new(my_params)
if @app.save
redirect_to app_path(@app)
else
render :new, alert: 'There was a problem'
end
end
private
def my_params
params.require(:app).permit(:title, :password)
end
The assignment logic is now being encapsulated in a private method to permit certain values to act as params.
Please use Devise 3.0.0.rc, which supports Rails 4.
You will need to:
Update Gemfile
:
gem 'devise', '3.0.0.rc'
bundle install
. 上一篇: 使用Rails Admin进行标记
下一篇: 耙子迁移中止