ruby on rails - How does devise know what table you want form data written to? -


here devise' 'sign up' view (new.html.erb).

<h2>sign up</h2>  <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) |f| %>   <%= devise_error_messages! %>    <div><%= f.label :email %><br />   <%= f.email_field :email, :autofocus => true %></div>    <div><%= f.label :password %><br />   <%= f.password_field :password %></div>    <div><%= f.label :password_confirmation %><br />   <%= f.password_field :password_confirmation %></div>    <div><%= f.submit "sign up" %></div> <% end %>  <%= render "devise/shared/links" %> 

i have table called 'users' want data go. when make account on system, data written users table, , works perfectly. how devise know want data go 'users'?

though beginning grasp on rails, how symbols :password, :email, ect equate database input? devise' source code, rather rails?

when define:

devise_for :users 

you tell devise define devise::mapping instance.

when go users/sign_in devise mapping instance users part of url.

this mapping object used user instance:

def resource   instance_variable_get(:"@#{resource_name}") end 

where resource_name mapping.name

you can check devisecontroller class uses mapping class in documentation


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -