Looking for method "l" and "t"
translate # Lookup text translations localize # Localize Date and Time objects to local formats
These have the aliases #t and #l
look at ActionView::Helpers::TranslationHelper
Community contributions, tips, and corrections to the documentation. (1708 notes)
translate # Lookup text translations localize # Localize Date and Time objects to local formats
These have the aliases #t and #l
look at ActionView::Helpers::TranslationHelper
Most blog articles about accepts_nested_attributes_for, including the one from @mattsa and @annaswims, tell you to add a
'_delete' => 1
when you want a deletion checkbox, hidden attribute, etc.
But this stopped being true a while ago. This is just a "Watch Out!" Make sure you use
'_des...
If you're upgrading to Rails 3 you'll need to make sure you include rails.js (which is in public/javascripts when you rails new someproject) You'll need to include it after prototype. And you'll need to have a 1.7 version of prototype.
When you do a link_to "Delete", @some_obj, :method => "d...
This seems to return ActiveSupport::TimeZone and not ::TimeZone as of v.3.0.0 and later.
Which cipher types (specified through the salt argument) are available will depend on what your platform natively supports. It should be noted that OSX up to at last 10.6 only provides the regular DES cipher. On most Linux platforms, however, you should have access to the following:...
If you are using a namespace in your routes.rb, for example:
namespace :admin do
resources :products
end
then you can:
url_for([:admin, @product])
and:
url_for([:edit, :admin, @product])
Yes, the only way round this seems to be to code e.g:
postArgs = { 'table[field]' => value, 'table[f2]' => v2 }
after the fashion of the browsers form definition.
This lets you do nested attributes as well, e.g: postargs['table[children_attributes[0][field]'] = value
@rkh You would be correct if this code had occurred in a subclass who's parent method was being overridden.
However, defining the method in this manner is completely removing the old method - as if you had written code like this:
class MyClass
def do_something
puts "We're doing some...
You just need to define default_url_options[:host] in your class. The easiest way to do it:
class SomeClass include ActionController::UrlWriter default_url_options[:host] = YourApp::Application.config.action_mailer.default_url_options[:host]
def some_method
some_superb_url(maybe_ev...
select_tag "people", raw("<option>David</option>")
If you are using a namespace in your routes.rb, for example:
namespace :admin do
resources :products
end
then you can:
url_for([:admin, @product])
and:
url_for([:edit, :admin, @product])
from 'man recvfrom' The flags argument to a recv() function is formed by or'ing one or more of the values:
MSG_OOB process out-of-band data
MSG_PEEK peek at incoming message
MSG_WAITALL wait for full request or error
The MSG_OOB flag requests receipt of out-of-...
It's also available to use after scope chain too, like in any other AR action, for example:
User.where('age > 69').delete_all
To pass arguments to block being captured, just list them as capture method params. I.e.
def export(exportable, export_klass, options={}, &block)
result = ""
#...
if block_given?
result += capture(my_custom_var_i_want_to_pass_to_block, &block)
end
result
end
Then...
jlength counts the non-unicode characters in a string to its actual length. Otherwise rails treat as 5 characters.
For case-insensitive uniqueness:
validate :username, :uniqueness => {:case_sensitive => false}
For example: validate :must_be_friends, :on => :create
In Rails 3 the returned value will be type cast to the column's type and not Float. So when calculating average on a column the column's type need to be float, the result will be truncated otherwise.
Also eliminates inadvertent double slashes:
path = '/uploads/art/'
file = '/pic.jpg'
File.join(path, file) # => '/uploads/art/pic.jpg'
Not sure why this isn't documented... there are callbacks for before/after_add and before/after_remove. Example
has_many :things, :after_add => :set_things, :after_remove => :remove_things
def set_things(thing)
...
end
def remove_things(thing)
...
end