Marcio Garcia

Software Empowerment²

Archive for the ‘RoR’ tag

Ubuntu + Ruby on Rails + Apache + Passenger

without comments

Guia expresso para instalação de um ambiente de produção RoR/Apache/Passenger no Ubuntu

sudo apt-get install rubygems
 
sudo gem install rails
 
sudo apt-get install ruby
 
sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby
 
wget http://rubyforge.rubyuser.de/rubygems/rubygems-1.3.1.tgz
 
tar xzvf rubygems-1.3.1.tgz 
 
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
 
sudo mv /usr/bin/gem /usr/bin/gem-old
 
sudo gem update --system
 
sudo gem install rails
 
sudo apt-get install build-essential ruby1.8-dev
 
sudo gem install mongrel
 
sudo gem install capistrano
 
sudo apt-get install mysql-client mysql-admin mysql-query-browser libmysqlclient15-dev
 
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
 
sudo gem install sqlite3-ruby
 
echo "export RUBYOPT=rubygems" >> ~/.profile
 
sudo apt-get install build-essential apache2-mpm-prefork apache2-prefork-dev libapr1-dev
 
sudo gem install passenger
 
sudo passenger-install-apache2-module
 

Written by Marcio

January 16th, 2009 at 12:17 am

Posted in Apache, RubyOnRails, Ubuntu

Tagged with , , ,

Screencast - restful_authentication

with 3 comments


restful_authentication - Screencast (pt-br) from Marcio Garcia on Vimeo.

Instalação do restful_authentication

URL do plugin:

http://svn.techno-weenie.net/projects/plugins/restful_authentication/

./scrpt/plugin source http://svn.techno-weenie.net/projects/plugins/restful_authentication/
 
./script/plugin install restful_authentication

Criação dos controllers e model padrão
./script/generate authenticated user sessions

Alterações de código

routes.rb
#novas rotas....
map.signup '/', :controller => 'sessions', :action => 'new'
map.signup '/signup', :controller => 'users', :action => 'new'
map.login  '/login',  :controller => 'sessions', :action => 'new'
map.logout '/logout', :controller => 'sessions', :action => 'destroy'

app/views/layouts/application.html.erb
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <%= stylesheet_link_tag 'scaffold' %>
</head>
<body bgcolor="#1471B7">
<center>
<p>&nbsp;</p>
<table width="90%"  bgcolor="#FFFFFF">
	<tr>
		<td align="center">
		<%= yield%>			
		</td>
	</tr>
</table>
</center>
</body>
</html>





app/controllers/application.rb
include AuthenticatedSystem

app/controllers/sessions_controller.rb
def new
  #alterado....................
  flash[:notice] = "Usuario logado!" if logged_in?
  flash[:notice] = "Usuario NÃO logado!" unless logged_in?
end

app/controllers/users_controller.rb
#alterado......................
before_filter :authentication
def authentication
  redirect_back_or_default('/') unless logged_in?
end

Código fonte

rademo.zip

Written by Marcio

November 7th, 2008 at 12:13 am