From: Tony Arcieri Date: 2010-08-13T15:17:24+09:00 Subject: Re: whats up buudy check out the login controller --00148501f6fb8e1394048dae6faa Content-Type: text/plain; charset=ISO-8859-1 Whats up buudy? What code is this? It looks a bit gnarly... On Thu, Aug 12, 2010 at 11:27 PM, Jimmy Andy wrote: > class LoginController < ApplicationController > def addprod > @category=Cattab1.find(:all) > @product=Prodtab.find(:all) > @i=0 > @checkvalue="" > end > > def login > @logincheck =Login.new > @prodcheck=Prodtab.new > if(session[:login_id]) > Login.update(session[:login_id],:user_status=>"0") > end > end > > def login_create > @login = Login.new(params[:login]) > if request.get? > session[:login_id] = nil > else > puts 'logincretaeeeeeeeeeeeeeeeeeeeeeeeeee' > puts params[:login][:password] > params[:login][:password] = > Login.hashed_password(params[:login][:password]) > puts params[:login][:password] > @logincheck = > > Login.find_by_name_and_password(params[:login][:name],params[:login][:password]) > if @logincheck == nil > #@logincheck.save > flash[:error] ="Name/Password not matching" > redirect_to :controller=>'login', :action=>'login' and > return > else > session[:login_id] = @logincheck.id > Login.update(@logincheck.id,:user_status=>"1") > redirect_to :controller=>'prodtabs', :action=>'index' > and return > end > end > end > > def category3 > puts '*****category3****' > @categyid=request.raw_post > session[:category_id]=@categyid.to_i > puts @categyid.to_i > @catlist=Cattab1.find_all_by_id(@categyid.to_i) > end > > def category4 > puts '*****category4****' > @productid=request.raw_post > puts @productid.to_i > @prodlist=Prodtab.find_all_by_id(@productid.to_i) > end > > def prod1 > puts '*******prodids********' > puts params[:product_id] > puts '*********vijay********' > @prodcheck1=params[:product_id] > @prodcheck=Prodtab.find_all_by_id(@prodcheck1) > @prodcheckcatid=Prodtab.find_all_by_cattab1_id(@prodcheck1) > @prodcheck.each do|p| > if p.cattab1_id==0 > Prodtab.update(p.id ,:cattab1_id=>session[:category_id]) > flash[:success] ="Product is assigned successfully" > else > flash[:error] ="#{p.pname} is already assigned" > redirect_to :controller=>'login', :action=>'addprod' and > return > end > #end > end > redirect_to:controller=>'login', :action=>'addprod' > end > end > > model > > class Login < ActiveRecord::Base > validates_uniqueness_of :name > > > def self.hashed_password(password) > Digest::SHA1.hexdigest(password) > end > end > > > views > > > > > > >
>

LOGIN FORM color>

>

<%= flash[:error] %>

> > > <% form_tag({ :controller => "login", :action => > "login_create"}, {:id=>"login", :name=>"login" ,:multipart => true}) do > %> > > > > > > > > > > > > > <% end %> >
Login ID <%= text_field 'login','name' %>
Password <%= password_field 'login','password' %>
onclick ="return compare1();"> > >
> > > -- > Posted via http://www.ruby-forum.com/. > > -- Tony Arcieri Medioh! A Kudelski Brand --00148501f6fb8e1394048dae6faa--