We just started a new Rails 4 site, and we decided to use RefineryCMS for some of it. Then I also installed Devise, for the parts of the site not covered by RefineryCMS.
Because some of the RefineryCMS plugins are written for Rails 3, we had to use protected_attributes gem, which offers a smooth upgrade path.
Our User model initially looked like this:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
However, when I filled out the form at registrations#new, I got 2 validation errors:
Email can't be blank
Password can't be blank
But I had filled both in. So I thought perhaps this was an issue with mass assignment. So I added this to the user model:
attr_accessible :email, :password, :password_confirmation,
:remember_me, :first_name, :last_name, :profile_name
So now I have:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation,
:remember_me, :first_name, :last_name, :profile_name
end
This fixed the problem with the password -- I no longer get an error about the password being blank. But I still get an error about email being blank.
Any suggestions about what I need to do to get email in there?
(For awhile there was a conflict with a second login form in the field, which appeared in a Javascript lightbox, but I have removed that.)
From the development log:
Started GET "/users/sign_up" for 127.0.0.1 at 2015-03-18 23:09:25 -0400
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.html.erb (0.3ms)
Rendered devise/registrations/new.html.erb within layouts/application (3.6ms)
Rendered vendor/bundle/ruby/2.1.0/bundler/gems/refinerycms-11f8d1eeb45e/core/app/views/refinery/_html_tag.html.erb (0.1ms)
Rendered refinery/_site_bar.html.erb (0.3ms)
Completed 200 OK in 25ms (Views: 22.6ms | ActiveRecord: 0.0ms)
Started POST "/users" for 127.0.0.1 at 2015-03-18 23:09:41 -0400
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"lERPLieT6htcLhC8yqBq00/6mz2AAfYzrFjTFEJ2lbg=", "user"=>{"email"=>"lawrence@krubner.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Unpermitted parameters: email
(0.1ms) begin transaction
(0.1ms) rollback transaction
Rendered devise/shared/_links.html.erb (0.4ms)
Rendered devise/registrations/new.html.erb within layouts/application (6.2ms)
Rendered vendor/bundle/ruby/2.1.0/bundler/gems/refinerycms-11f8d1eeb45e/core/app/views/refinery/_html_tag.html.erb (0.1ms)
Rendered refinery/_site_bar.html.erb (0.3ms)
Rendered _login.html.erb (0.1ms)
Completed 200 OK in 141ms (Views: 40.7ms | ActiveRecord: 0.2ms)
I followed the advice here exactly:
rails-4-devise-mongodb-unpermitted-parameters-using-custom-properties
which did not change anything for me.
I don't think I have custom properties, but it is true that we installed RefineryCMS. I am not sure if its ideas about the user model is in conflict with what Device is trying to do. How would I test to see which model is being used? The route belongs to Device so I'm assuming the Device code would govern this situation.
[UPDATE]
huh, well, this at least got me a different error:
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:email,:password,:password_confirmation)
end
end
Now I have a routing error.