ruby on rails - Problems setting up AuthLogic -


I am trying to set up a simple login in my user table using AuthLogic. Every time I try, the login fails and I do not know why I'm sure this is a simple error, but I'm killing a brick wall with it for a while.

  #user_sessions_controller def can create @user_session = user session. New (Parameters [: user_session]) If @ user_session.save flash [: notice] = "Login successful!" Else flash [: Notice] = "We were unable to log you in. Please try again!" Redirect_to: Controller = & gt; "Index" ,: verb = & gt; "Index" end and # _user_login.html.erb (This is partial from my index page where users are logged in) & lt;% form_tag user_session_path please% & gt; & Lt; P & gt; & Lt; Label = "login" & gt; Login: & lt; / Label & gt; & Lt;% = text_field_tag ​​"Login", zero ,: class => "Input Box" ,: id = & gt; "Login", & lt; / P & gt; & Lt; P & gt; & Lt; Label = "password" & gt; Password: & lt; / Labels & gt; & Lt;% = password_field_tag ​​"password", zero ,: class = & gt; "Input Box" ,: id = & gt; "Password", & lt; / P & gt; & Lt; P & gt; & Lt;% = submit_tag "Submit" ,: class = & gt; "Submit"%> & Lt; / P & gt; & Lt;% end% & gt;  

The faker with me used to generate some data for my user table but I could not log in! Every time I try, it only redirects to the index, where is I going to mistake? thanks all.

------ Update ------

I have implemented the suggestion of Jacob Happel for now - I'm getting a new error.

ActionView :: TemplateError (For idle id is called, which will be mistakenly 4 - 1: <% form_for @user_session do | f |%> 2: & lt;% if Flash [: Notice] -%> 3: & lt; p class = "notice"> <% = Flash [: notice]%> 4: & lt ;% End -%> App / view / index /_user_login.html.erb:1 app / view / layout / index.html. ARB: 65 app / controller / index_controller .rb: 3: `index ' Switch to render the rescue / _trres (86.0 mms) were rendered rescue / _request_and_response (1.0 ms)) saved rendering / layout (internal_server_error)

I have not changed any controller at all. Thanks to everyone who responded to this topic - it is incredibly useful to me. What can I do now that this obstacle is the last?

------ Update # 2 ------

Here's my application controller.

  def current_user_session return @current_user_session if defined? (@Content_user_session) @current_user_session = UserSession.find End Def current_user return @current_user if defined? (@ Current_user) @cur Rent_user = current_user_session & amp; Amp; Current_user_session.user end def require_user until current_user store_location flash [: notice] = "you must be logged in to access this page" redirect_to login_path returns and f and def need_no_user if current_user store_location flash [: notice] = "you log This page should be "redirect_to root_url return false end end  

to reach this page, which should be changed to any of these @user_session?

form_for :

  & lt;% form_for @user_session do | f | & gt;; & gt; & lt;% = f.label: Username% & gt; & lt;% = f.text_field: Users Name, class = & gt;: input box%> gt; & lt; / p & gt; & lt; p & gt; & lt;% = f.label: password% & gt; & lt;% = f Password_field: password ,: class = & gt;: input box%> << p>  & lt; / p & gt; & lt;% end% & gt;  

In addition to that hard work, Try adding errors to the table so that you can see what's going wrong.

Since this is your last update, it seems that the user_session is not set , Just go ahead and create one: & lt;% form_for UserSession.new do | f |% & gt; .


Comments