Tuesday, September 22, 2009

ROR open source web development





Sample Ruby on Rails Controller Coding in Signup form

$time = Time.new
$last_login_time
$i
class UserAccountController < except =""> :checkuser
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# If you want "remember me" functionality, add this before_filter to Application Controller
#before_filter :login_from_cookie

# say something nice, you goof! something sweet.


def index
redirect_to(:action => 'signup') unless logged_in? || User.count > 0
if session[:username] != nil
redirect_back_or_default(:controller => '/user', :action => 'index')
end
end

def login
if session[:username] != nil
redirect_back_or_default(:controller => '/user', :action => 'index')
end
return unless request.post?
self.current_admin = User.authenticate(params[:login], params[:password])
if logged_in?
if params[:remember_me] == "1"
self.current_admin.remember_me
cookies[:auth_token] = { :value => self.current_admin.remember_token , :expires => self.current_admin.remember_token_expires_at }
end
@usname = params[:login]
@id = User.find(:first, :conditions => ["login = ?",@usname])
session[:user_id] = @id.id
session[:username] = @id.login
#session[:admin] = nil
$last_login_time = @id.last_login
$i = 1
@id.update_attribute([:last_login], params[:login_time])
if session[:price] == nil or session[:price] == 0
redirect_back_or_default(:controller => '/user', :action => 'index')
flash[:notice5] = ""
else
redirect_back_or_default(:controller => '/user', :action => 'purchase_ticket')
flash[:notice6] = ""
end
else
flash[:notice10] = "Username password mismatch"
redirect_to :action => 'signup'
end
end

=begin
@raffles = Raffle.new(params[:admin_new_raffle])
@mugshot = ProductImage.new(params[:mugshot])
@raffles.raffle_started_at = @abc
@raffles.raffle_ended_at = @xyz
if @raffles.save
@mugshot.save
@id = Raffle.find(:last)
flash[:notice] = 'New raffle was successfully created.'
redirect_to :action => 'raffle_info', :id => @id.id
else
render :action => :create_new_raffle
end
=end

def signup
if session[:username] != nil
redirect_back_or_default(:controller => '/user', :action => 'index')
else
@user = User.new(params[:user])
#return unless request.post?
if @user.save
self.current_admin = @user
session[:username] = params[:user][:login]
@id = User.find(:first, :conditions => ["login = ?",session[:username]])
@user_id = (@id.id).to_i
session[:user_id] = @user_id
if session[:price] == nil or session[:price] == 0
redirect_back_or_default(:controller => '/user', :action => 'index')
flash[:notice7] = ""
else
redirect_back_or_default(:controller => '/user', :action => 'purchase_ticket')
flash[:notice8] = ""
end
#rescue ActiveRecord::RecordInvalid
else
flash[:signup123] = "Registration failed"
render :action => 'signup'
end
end
end

def logout
self.current_admin.forget_me if logged_in?
cookies.delete :auth_token
#reset_session
flash[:notice9] = ""
session[:username] = nil
session[:user_id] = nil
session[:price] = nil
redirect_back_or_default(:controller => '/user', :action => 'index')
end

def testing
@user = User.new(params[:user])
if @user.save
redirect_back_or_default(:controller => '/user', :action => 'index')
else
redirect_back_or_default(:controller => '/user_account', :action => 'index')
end
end
end



Affordable web development in USA and Canada

Softlogic Inc is a professional web development company in USA and Canada. We specialize in web development and web design, but we also place a lot of focus on marketing our websites and businesses. That's because we know that having a world class website alone is not enough for your business growth. You have to market those web site so that Internet users can find you easily. Our dedicated web developers will work for your business growth still you reach your business goal. We develop your website with latest technology to ensure that the web site gets outstanding results.
Softlogic offers web design and web development services using PHP, Smarty, Zend Framework and open source customizations like Joomla, X-cart, Zen Cart, OS Commerce, Magento Commerce, Word Press etc.
Softlogic offers Content Management Solutions (CMS), Social Networking Solutions, and Custom Shopping Carts at affordable prices with high quality.
We assure your business growth through our affordable web services.
Dedicated Team
We offer Experienced, skilled, highly qualified and technically proficient team who, sit at our offshore center but dedicated to your projects. Our professional, experienced Dedicated Team will coordinate and adhere with the client’s requirements and time schedules to ensure timely completion of the process.
Project Based Team
Our team of experience developers will study your requirements, business objectives, project expectations and preferences. Our Project Development model has a unique distinction of providing efficient software solutions with cost and quality advantage, having the capacity to handle large projects and the ability to execute timely deliveries.
You can visit http://www.softlogiccorp.com for all web solutions and for outsourcing and offshore options.

Phone:302 613 0469 (USA)
mail:support@softlogiccorp.com