twitter bootstrap - Sorcery and Simple Form implementation -
long time reader first time user. i'm putting first ror application , i've isolated app should use down to:-
- sorcery
- omniauth
- cancan
- twitter-bootstrap (converted sass)
and simple forms.
clean, clear , simple....not.
cannot life of me integrate (what seem simplest of tasks) simple forms sorcery "login" without getting errors on 'remember_me' field.
simple forms doesn't have simple_form_tag (only simple_form_for) option work best on login form sessions controller new method. instead have create @user instance in method, errors on 'remember_me' field "undefined method `remember_me'"
any appreciated.
i mean greatly! huge thanx in advance :)
sessions/new.html.erb <% provide :title, "log in" %> <h1>log in</h1> <%= simple_form_for @user, :html => { :class => 'form-horizontal' } |f| %> <fieldset> <legend>login</legend> <%= f.input :email, input_html: { :maxlength => 100 } %> <%= f.input :password, input_html: { :maxlength => 20 } %> <%= f.input :remember_me, as: :boolean %> <div class="form-actions"> <%= f.submit nil, :class => 'btn btn-primary' %> <%= link_to 'cancel', users_path, :class => 'btn' %> </div> </fieldset> <% end %> class sessionscontroller < applicationcontroller def new @user = user.new end
the documentation says:
form_tag(url_for_options = {}, options = {}, &block) starts form tag points action url configured url_for_options actioncontroller::base#url_for. method form defaults post.
this indicates form_tag
intended send data directly url, handled controller action. indeed, in railstutorial signin form, michael hartl uses form_for
function instead of form_tag
.
form_for(:session, url: sessions_path)
basically, idea you're sending data handled controller in way, instead of writing database. since don't have model user sessions, have use :session
symbol instead of @session
, tell form (which url) should post data to.
i suspect, though i'm not sure, should work simple_form_for
well. like:
<%= simple_form_for(:session, url: sessions_path) |f| %>
update: changed reference implementation of sample app use simple_form_for
creating new user sessions.
that is, of course, assuming sessions controller handling login, , has method responds post (probably create
). controller action should handling sorcery login.
here's rails documentation form_for
, if you're curious.
Comments
Post a Comment