Reputation: 813
I'm using rails 4 with mongoid and a devise gem. I added some fields in user.rb.
class User
include Mongoid::Document
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
field :profile_name, :type => String
field :type, :type => String
field :gender, :type => String
field :location, :type => String
field :about, :type => String
...
end
I also edited registration and edit forms:
<div><%= f.label :profile_name %><br />
<%= f.text_field :profile_name, :autofocus => true %></div>
<div><%= f.label :type %><br />
<%= f.text_field :type, :autofocus => true %></div>
<div><%= f.label :gender %><br />
<%= f.select :gender, options_for_select(%w[Male Female]), :prompt => "Select your gender" %></div>
But it only saves standart information as: email and password. I thought of adding strong _params, but there is no user_controller.rb in my project folder.
And server crushes and won't start even if i add:
gem 'strong_parameters'
in the gemfile. I don't know what's my problem. Otherwise, I can add posts and they're stored ok.
Upvotes: 0
Views: 55
Reputation: 1266
Firstly, make sure you read through Devise fully with Rails 4. You need to setup strong params in the application_controller.rb
Rails 4 uses strong_params by default so there is no need to try and install it. You will need to add the attributes you require depending on the way you do it in the application_controller.rb
Just like sevencats said:
https://github.com/plataformatec/devise
Read the documentation and understand how devise works, it can cause alot of pain if you don't really understand what is going on.
I would suggest trying to build a system from scratch first using this tutorial:
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
He goes through a full user system from scratch.
Upvotes: 1