Hi, In this controller i''ve to put the condition for attandance. I''m doing attandance application. In this when the user login with username and password in my attandance table their attandance will marked. now i want to put the condition that in one day only once their data should go in to attandance table. If they logged in second time in same day the data should not go into my table. The should check with date and name. How can i do this. Please help me to get the answer. Thanks, Manjula Attachments: http://www.ruby-forum.com/attachment/1049/admin_controller.rb -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 27, 2007, at 11:23 PM, Manjula Rajendran wrote:> In this controller i''ve to put the condition for attandance. I''m doing > attandance application. In this when the user login with username and > password in my attandance table their attandance will marked. now i > want > to put the condition that in one day only once their data should go in > to attandance table. If they logged in second time in same day the > data > should not go into my table. The should check with date and name. How > can i do this. Please help me to get the answer.What''s happening now? Does it never find the previous login? Is date a Date or a Time? If the database has it as a datetime then Date.today isn''t going to match it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, Yes it is not finding the previous login. How may times i''m logging in the data going into my attandance table. I don''t want this. Only once it should go in a day. -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 28, 2007, at 12:28 AM, Manjula Rajendran wrote:> Yes it is not finding the previous login. How may times i''m logging in > the data going into my attandance table. I don''t want this. Only > once it > should go in a day.Is your date column a date or a datetime? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My date column is simple date -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 28, 2007, at 12:41 AM, Manjula Rajendran wrote:> > > My date column is simple dateNow I see it. You are mixing attandance and @attandance, which are not the same variable. (By the way, not that it matters here, but it''s attendance, with an e.) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
what is the condition do i have to write there? -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 28, 2007, at 1:15 AM, Manjula Rajendran wrote:> what is the condition do i have to write there?You just have to be consistent. If you do attendance = Find... then you have to do if attendance, not if @attendance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve done like this. but also it is not doing anything for my table. Data is entering into the table. What is the problem here Attachments: http://www.ruby-forum.com/attachment/1051/admin_controller.rb -- 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 -~----------~----~----~----~------~----~------~--~---
def login session[:user_id] = nil if request.post? user = User.authenticate(params[:name], params[:password]) if user session[:user_id] = user.id if user.user_type==''admin'' redirect_to :controller =>''admin_information'',:action=>''emp_list'' elsif(user.user_type==''user'') p "-------------finding in db-----------------" attandance = Attandance.find(:first, :conditions=>[''name=? and date=?'',user.name,Date.today]) if attandance flash[:notice]="Already entered" redirect_to :controller=>''information'', :action=>''emp_list'' else time_in = Time.now if time_in.hour > 10 and time_in.min > 10 attandance Attandance.create(:time_in=>Time.now,:name=>user.name,:present=>''late'',:date=>Date.today,:information_id=>@information_id) else attandance Attandance.create(:time_in=>Time.now,:name=>user.name,:present=>''Yes'',:date=>Date.today,:information_id=>@information_id) end #if @attandance.name==user.name and @attandance.present==''yes'' #attandance = Attandance.find(:first, :conditions=>[''name=? and date=?'',user.name, Date.today]) # if @attandance #flash[:notice]="Already entered" #else p "------#{@information_id}-----------" #attandance Attandance.create(:time_in=>Time.now,:name=>user.name, :present=>''Yes'',:date=>Date.today,:information_id=>@information_id) #@people = Person.find_recent # @attandance = Attandance.time_in #end flash[:notice]="Your attandance is marked" redirect_to :controller =>''information'',:action=>''emp_list'' end end #redirect_to :controller=>"admin_information", :action => "emp_list" else p"---------no msg-------------" flash[:notice] = "Invalid user/password combination" end end end changed if @attandance To if attandance. Suggestion: Better to move logic of late coming into corresponding model. (write UT''s) Note: If you are not sure when to use @attendance and attendance, please read Ruby book OR Ask some one. Thanks, Regards, Raghu Kumar K --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---