Paul Sturgess posted a nice little tip on how to How to use Capistrano 1.x to deploy Ruby on Rails apps when you have Cap 2.x. Basically, the following syntax will allow you to choose which version of a gem to run:
cap _1.4.1_ deploy
Or say you want to generate a 1.2.3 rails app:
rails _1.2.3_ […]
The fellows over at Err have finally seen the light of jQuery. My first thought is welcome to the party, we’ve been wondering when you’d get here. From my first days with rails, I’ve been using jQuery over Prototype. Why? Well, a lot of reasons, but the biggest one is because […]
Taking Merb to Production
A good up and running with Merb tutorial.
¶
Posted 24 December 2007
§
Merb
‡
°
has_many :through: Finding unassociated objects
Awesomeness.
¶
Posted 24 December 2007
§
Tips
‡
°
Everyone loves before_create and before_save. Recently it came in very handy for logging hits to objects. If the user is logged in, I want to store the user’s full name and the user’s type, otherwise, keep those null. So I added this to my PostHit model:
def before_create
if self.user
self.user_name = […]
There is this helpful method I’ve been evolving in my apps for a bit, it’s called render_either and it goes a little something like this: (in application.rb)
def render_either(opts = {})
# For MIME:Type Recognition
# respond_to do |f|
# f.js {@wants = […]
I previously discussed the difference between flash.now[:notice] and flash[:notice]. I ended with a summarizing rule that says when you end an action with render, you generally want to use flash.now[:notice], and when you end an action with redirect, you want to use flash[:notice]. While simple, I hate remembering that rule, and what really complicates things […]
¶
Posted 17 December 2007
§
Rails
‡
°
Tagged: flash
You’re just starting on rails and you’re very excited about the ease of flash[:notice]. But every now and then, you set a flash notice and it seems to follow your clicks to the next action when it shouldn’t. Why? I’ll tell you.
Intro to flash[:notice]
flash[:notice] belongs to FlashHash.The basic use of the flash hash […]
¶
Posted 15 December 2007
§
Rails
‡
°
In my Rails controllers, I have a lot of this:
@project = Project.find(params[:project])
if @project
@project_product = @project.project_products.create(params[:project_product])
if @project_product.valid?
# Do something with success
else
# Do something with error
end
else
# Do something with error
end
The thing that I don’t like about that style is that the […]