no overwrite
const_set does not overwrite, it only create new ones
Community contributions, tips, and corrections to the documentation. (1708 notes)
const_set does not overwrite, it only create new ones
The example Ramon gave works within the model itself, i.e.
class Article
def closed
with_exclusive_scope { find(:all) }
end
end
However, from what I can see, this approach does not work within a controller. You may be wanting to use
Article.with_exclusive_scope { find(:a...
Get the current database name when using Sqlite:
ActiveRecord::Base.connection.instance_variable_get(:@config)[:database].split('/').last
Some of the more commonly used signals:
1 HUP (hang up)
2 INT (interrupt)
3 QUIT (quit)
6 ABRT (abort)
9 KILL (non-catchable, non-ignorable kill)
14 ALRM (alarm clock)
15 TERM (software termination signal)
Be aware that if you want to send emails with attachments, you probably want to use the content type +multipart/mixed+ for the overall email.
The MIME time +multipart/alternative+ is intended for emails where each part is a different representation of the same message.
After following the 2.3.2 do...
Actually it's easier to use validates_format_of for this task. Please refer to the comments under the doc.
It's easy to join multiple tables too. In this case we have:
class Article
belongs_to :feed
end
class Feed
has_many :articles
belongs_to :source
end
class Source
has_many :feeds
# t.bool :visible
end
You can search articles and specify a condition...
Built-in cache stores are:
Most common use case is probably:
Rails.cache.fetch "some key" do
compute some value
end
This computes some value and caches it. Subsequent invocations will return cached value (as long as it is still cached).
This method only returns a cache manager object of sorts, to see what you can do with it, see ActiveSupport::Cache::Store.
When adding the :target option, the documentation states that you should user :href_options like so:
auto_link(post_body, :href_options => { :target => '_blank' })
However, I could only get it to work using :html instead:
auto_link(post_body, :html => { :target => '_blank' })
I'm using Rails 2...
@taryneast, the second example is correct. The receiver's #size limits the result's.
nachokb
The documentation is referring to the module documentation: ActionController::Cookies
Supplying the binding argument produces a deprecation warning in 2.2 and newer:
DEPRECATION WARNING: The binding argument of #concat is no longer needed. Please remove it from your views and helpers.
==== Example to display an array as yaml formatted output
require 'yaml'
puts [100, [99, 98, 97], 96, 95].to_yaml
Option :datetime_separator can be set too. Default is ' — '
==== File.exist?("/path/to/file_or_dir")
Synonym for File.exist?
To set default value to NULL you can use change_column method instead, for example:
change_column :suppliers, :qualification, :string, :default => nil
Just make sure you don't change data type accidentally ;-)
I had a sortable_element that was also a drop_receiving_element. element it's dropping while dropping element into selected container ,but not element dragging is not viewble to end users. it's dragging only in sortable list area. but mu droppble contanier is another one.i used scroll => true in so...