#26 - 6 min
#47 - 9 min
#48 - 10 min
#62 - 11 min
#134 - 7 min
#140 - 4 min
#152 - 9 min
#154 - 8 min
This are the numbers of Railscasts episodes that every Rails newbie should watch (obligatory for every newcommer in our company).
#26 - 6 min
#47 - 9 min
#48 - 10 min
#62 - 11 min
#134 - 7 min
#140 - 4 min
#152 - 9 min
#154 - 8 min
This are the numbers of Railscasts episodes that every Rails newbie should watch (obligatory for every newcommer in our company).
If you are missing Webrats http_accept method after migrating from Webrat to Capybara this c’d be solution for rack based driver:
page.driver.header "Accept", "application/javascript"Tired of typing User.find_by_verylongattribute_name(‘something’) into rails console? This little alias made my day:
class User < ActiveRecord::Base
def self.[](arg)
self.find_by_userlogin(arg)
end
end
Usage:
>> User['madsheep']
=> #<User id: 1, userlogin: "madsheep">
While developing our latest application, we discovered that Mongoid doesn’t save embedded objects when their parent is saved. On the GitHub page of this issue there were suggested some solutions and it appears that one posted by mcasimir works very well. What happened to be the next problem is that with this solution comes the issue with saving attachments’ filenames. We’ve found a solution somewhere on GitHub and changed it a little so it works with overriding filenames :
after_validation :extract_filename
def extract_filename
img_original_filename = img.instance_variable_get("@original_filename")
if self.img.class.filename and img_original_filename.present?
self.img_filename = self.img.class.filename
elsif img_original_filename.present?
self.img_filename = img_original_filename
end
end
Each time someone thinks it’s a good idea to create model without timestamps or use habtm instead of hmt - Mighty God kills little kitten.
http://adam.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/
Those two solutions can be easily combined to transfer mysql database from one development machine to another (no more nasty dump emailing/sending/sharing etc.)
On first machine:
taps server mysql://db_user:db_pass@localhost/database_name online_user online_pass -p 5000proxylocal 5000
Last command will pop out an address (like http://tz87.t.proxylocal.com/ or similar)
And second machine (to obtain sqlite database):
taps pull sqlite://development.sqlite3 http://online_user:online_pass@tz87.t.proxylocal.com
How cool is that?
set_property :delta_column => 'another_delta_field'
Adding this property to sphinx indexes on your model allows you to use different field name then ‘delta’ for delta indexing - useful when two stages of your application share the same database.
Very simple way to use FQL in Fgraph (https://github.com/jugend/fgraph) with query caching.
require 'digest/sha1'
module FGraph
class Client
def fql(query)
@cached_query ||= {}
@cached_query[Digest::SHA1.hexdigest(query)] ||= HTTParty.get("https://api.facebook.com/method/fql.query", :query => {:query => query, :access_token => self.options[:access_token], :format => :json} )
end
end
end