Tuesday, 31 July 2012

Change the db with migrations on the fly

What if you want to add a column though the console with one line of code? (and you exactly know what this implies)
ActiveRecord::Migration.new.add_column :payments, :card_verification, :string, limit: 8
ActiveRecord::Migration.new.execute "full sql here"

Saturday, 14 July 2012

Coffescript rendering

The correct way to render html inside your XHR response in Rails.

  app.showFlashMessages('<%=j flash_messages %>')
  $('.booking').replaceWith( '<%=j render @booking %>' )
  app.myFunction( <%=raw array.map(&:to_json) %> ) # TODO: double check