Notes
Community contributions, tips, and corrections to the documentation. (1708 notes)
Video Explanation of first, last and each
Video Explanation for map
Video Explanation for max and min
Video Explanation For min and max
Add html5 scriipt async attribute
http://www.w3schools.com/html5/att_script_async.asp
javascript_include_tag "application", :async => true
Video Explanation of drop_while
Video Explanation of drop and drop_while
Video Explanation of member?
Video Explanation of the tap method
Video Explnation of the collect method
Video Explanation of find and find_all
Video Explanation of find and find_all
flash messages
In rails 3.1 the following does not work for me
redirect_to { :action=>'atom' }, :alert => "Something serious happened"
Instead, you need to use the following syntax (wrap with parens)
redirect_to({ :action=>'atom' }, :alert => "Something serious happened")
Example of conditions using
==== f.e. validates :number, :presence => { :if => :quota_file? }
def self.quota_file?
quota_file?
end
won't refresh updated_at
This will not cause :updated_at column to refresh, while ActiveRecord::Base#increment! would.
looking to bypass validations, callbacks and updated_at?
Take a look at updated_column
http://apidock.com/rails/ActiveRecord/Persistence/update_column
Be careful with path vs. endpoint
URI.join uses a delimiter -- forward slash (/) -- to decide if joined strings are a path or endpoint. In order to include strings as part of the path, they must end with a forward slash (/). Otherwise, they are assumed to be an endpoint and are overritten by your new "endpoint".
Used this way,...
How to user method 'from'
==== example
User.from('posts').to_sql
# => "SELECT users.* FROM posts"
How to user method from'
==== example
User.from('posts').to_sql
# => "SELECT users.* FROM posts"