i m new to ROR..........
i make a simple progm for login..........
Username and password.......
if(right)
{
login
}
else
{
error msg
}
can u help me in this..........
My form is
************************************************************************
<% form_tag :controller => "user", :action =>
"login_submit" do %>
<p class="input_fields"><label>Username:
</label>
<input id="user_username" name="user[username]"
size="15" type="text"
/></p>
<p class="input_fields"><label>Password:
</label>
<input id="user_password" name="user[password]"
size="15"
type="password" /></p>
<%= submit_tag "Login"%>
<% end %>
***************************************************************************
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
looks good to me. What''s the problem? On Mon, Apr 28, 2008 at 1:34 PM, Manish Nautiyal <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i m new to ROR.......... > i make a simple progm for login.......... > > Username and password....... > > if(right) > { > login > } > else > { > error msg > } > > can u help me in this.......... > My form is > ************************************************************************ > <% form_tag :controller => "user", :action => "login_submit" do %> > <p class="input_fields"><label>Username: </label> > <input id="user_username" name="user[username]" size="15" type="text" > /></p> > <p class="input_fields"><label>Password: </label> > <input id="user_password" name="user[password]" size="15" > type="password" /></p> > > <%= submit_tag "Login"%> > <% end %> > *************************************************************************** > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roger Pack wrote:> looks good to me. What''s the problem? > > On Mon, Apr 28, 2008 at 1:34 PM, Manish Nautiyalmy action is def login_submit if session[''user''] @logged_in = true else @logged_in = false end @user = User.new(params[''user'']) if session[''user''] = User.authenticate(params[''user''][''username''], @params[''user''][''password'']) flash[:notice] = l(:user_login_succeeded) redirect_to :action => ''welcome'' else @login = @params[''user''][''login''] flash.now[:notice] = l(:user_login_failed) end end ------------------------------------------------------------ ERROR IS ------- NoMethodError in UserController#login_submit You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
there are two lines that seem a bit strange... @user = User.new(params[''user'']) why create an User object during login? or do you want to make sure, a user with this username/password does exist? in this case you would have to save the thing. (and make sure, the creation does not fail) and this line: @login = @params[''user''][''login''] it should be params of course without the @. but still there is no input field "login" in your form. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---