Rails permissions when using passenger fusionSection: Ruby on Rails
 When using passenger fusion for hosting your rails sites, the rails process is owned by the user who owns config/environment.rb

So make sure that user can write to /tmp, /log and /public !

cross-subdomain sessionsSection: Ruby on Rails

If you want your session to be valid across multiple sub-domains, here is how you do it:

 config.action_controller.session = {

   :session_key => 'xxxxxxxxxxxxxxxx',
   :session_domain => 'domain.tdl',
   :secret => 'yyyyyyyyyyy'
}
 
 

 

rails 2.2.2 & mysql & leopardSection: Ruby on Rails

if you get this error after upgrading to Rails 2.2.2:

 

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

You can fix it with:

 

 

sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
  --with-mysql-include=/usr/local/mysql/include

 

Check if object has associated attribute methodSection: Ruby on Rails
if you want to check if an object has an associated attribute method:

if a person has_one image and a gallery has_many images:

gallery.respond_to?(:images)
# => true
gallery.respond_to?(:image)
# => false
person.respond_to?(:images)
# => false
person.respond_to?(:image)
# => true
before_filter and return falseSection: Ruby on Rails
It looks like Rails 2.0 will no longer pay attention to the return value of before_filters. Currently, in our Pre-Rails 2.0 world, before_filters stop processing a request when they encounter a return value of false. You may recognize the common pattern:
  redirect_to new_session_path && return false
Rails 2.0 won't require a return value of false for a before_filter to stop the action, but will instead look to see if you called redirect_to or render. If either of these functions are called the filter chain is halted. This should clean up a lot of code and remove a lot of repetition. At the end of the day your before filters look almost the same as they always have, just drop the
&& return false
Sections 
- PHP (1)
- General (2)
- Ruby on Rails Snippet (3)
- Ruby on Rails (13)
- HTML (1)
- Css (1)
- regex (1)
- Photoshop (1)
- Leopard (1)
A little note to Internet Explorer users:
This site is not made for Internet Explorer. Some pages may look like shit. Yes, i could fix it for IE, but no, I'm not gonna do it. Try Opera or Firefox instead!