add fields to polymorphic devise user rails 4 -


i have rails app, using devise users. have 2 types of users share fields , have own. made polymorphic models 2 types. when added fields base devise user, form adding new user doesn't seem recognizing new fields.

devise user

class user < activerecord::base    devise :database_authenticatable, :registerable,      :recoverable, :rememberable, :trackable, :validatable    belongs_to :meta, polymorphic: true end 

polymorphic artist model

class artist < activerecord::base     has_one :user, as: :meta, dependent: :destroy     has_and_belongs_to_many :artist_expertises     accepts_nested_attributes_for :user      has_many :connections     has_many :teachers, through: :connections end 

overwriting devise registrations

class registrationscontroller < devise::registrationscontroller     private      def sign_up_params         params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation)     end      def account_update_params         params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password)     end  end 

routes

rails.application.routes.draw  ...   resources :artists   resources :teachers   devise_for :users, :controllers => { registrations: 'registrations' } ... end 

then on following _form used in new page artist fine email , password fields devise default. next user_fields.label :first_name field added users table errors (undefined local variable or method `user_fields' #<#:0x007f9c81b3a108> did mean? number_field)

views/artist/_form.html.erb (rendered in new view)

<%= form_for(setup_artist(@artist)) |f| %>     <% if @artist.errors.any? %>     <div id="error_explanation">       <h2><%= pluralize(@artist.errors.count, "error") %> prohibited artist being saved:</h2>        <ul>         <% @artist.errors.full_messages.each |message| %>         <li><%= message %></li>         <% end %>       </ul>     </div>     <% end %>      <%= f.fields_for :user |user_fields| %>     <div class="field">       <%= user_fields.label :email %>       <%= user_fields.text_field :email %>     </div>     <div class="field">       <%= user_fields.label :password %>       <%= user_fields.text_field :password %>     </div>     <% end %>       <div class="field">       <%= user_fields.label :first_name %><br />       <%= user_fields.text_field :first_name %>     </div>      <div class="field">       <%= user_fields.label :last_name %><br />       <%= user_fields.text_field :last_name %>     </div>      <div class="field">       <%= f.label :inspiration %><br>       <%= f.text_area :inspiration %>     </div>      <div class="field">       <%= f.label "area of expertise" %><br />       <%= f.collection_check_boxes :artist_expertise_ids, artistexpertise.all, :id, :name |b| %>       <div class="collection-check-box">         <%= b.check_box %>         <%= b.label %>       </div>       <% end %>     </div>       <div class="actions">       <%= f.submit %>     </div>     <% end %> 

welp, i'm ding dong. had <% end %> before added user fields. ya bing bongs.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo