:use_month_numbers - Set to true if you want to use month numbers rather than month names (e.g. “2” instead of “February”). :use_short_month - Set to true if you want to use abbreviated month names instead of full month names (e.g. “Feb” instead of “February”). :add_month_numbers - Se...
This method allows you to serialize an Array of Ruby objects to a String or File of CSV data. This is not as powerful as Marshal or YAML, but perhaps useful for spreadsheet and database interaction. Out of the box, this method is intended to work with simple data objects or Structs. I...
Strips indentation in heredocs. For example in if options [ :usage ] puts <<- USAGE . strip_heredoc This command does such and such. Supported options are: -h This message ... USAGE end the user would see the usage message aligned against the left margin. Technically, it looks for the...
From the man page: If salt is a character string starting with the characters “$id$” followed by a string terminated by “$”: $id$salt$encrypted then instead of using the DES machine, id identifies the encryption method used and this then determines how the rest of the password string ...
Returns a new array with the concatenated results of running block once for every element in enum . If no block is given, an enumerator is returned instead. [[ 1 , 2 ],[ 3 , 4 ]]. flat_map {| i | i } #=> [1, 2, 3, 4]
that you can’t use immutable objects like numbers, true or false as the memo. You would think the following returns 120, but since the memo is never changed, it does not.
This will provide all three standard callbacks (before, around and after) for both the :create and :update methods. To implement, you need to wrap the methods you want callbacks on in a block so that the callbacks get a chance to fire:
Coding test and analyzer @ DupCode We are soon launching DupCode.com, at which you can test and analyze your coding skills, compete with friends and at the same time pave the way to professional coder Come drop your email at DupCode.com and we will inform you the minute we launch!
Returns an instance of the specified klass with the attributes of the current record. This is mostly useful in relation to single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record identification in Action Pack to all...
This command will create following directories and install files onto them. * ${DESTDIR}${prefix}/bin * ${DESTDIR}${prefix}/include/ruby-${MAJOR}.${MINOR}.${TEENY} * ${DESTDIR}${prefix}/include/ruby-${MAJOR}.${MINOR}.${TEENY}/${PLATFORM} * ${DESTDIR}${prefix}/lib * ${DESTDIR}${prefix}...
class method to easily expose contained objects’ methods as your own. Pass one or more methods (specified as symbols or strings) and the name of the target object via the :to option (also a symbol or string). At least one method and the
Eval the given block. All methods available to the current connection adapter are available within the block, so you can easily use the database definition DSL to build up your schema (create_table, add_index, etc.). The info hash is optional, and if given is used to define metadata a...
it will be substituted for the matched text. It may contain back-references to the pattern’s capture groups of the form \d, where d is a group number, or \k<n>, where n is a group name. If it is a double-quoted string, both back-references must be preceded by an additional backslash. ...
%a - The abbreviated weekday name (“Sun”) %A - The full weekday name (“Sunday”) %b - The abbreviated month name (“Jan”) %B - The full month name (“January”) %c - The preferred local date and time representation %d - Day of the month (01..31) %H - Hour of the day, 24-hour clock (00..23...
Removes the definition of the given constant, returning that constant’s value. Although predefined classes/modules also can be removed, they just can’t be refered with the names but still exist. It could cause very severe confusion. Feel Free to Shoot Your Own Foot.
Register or log in to add new notes. mutru - October 10, 2008 7 thanks Implemented in database adapters These methods are not implemented in the abstract classes. Instead, all database adapters implement these separately, if the feature is supported. Vidmantas - July 30, 2009 2 thanks...
to the block. This simplifies the process of constructing an object, performing work on the object, and then returning the object from a method. It is a Ruby-ized realization of the K combinator, courtesy of Mikael Brockman.
to the block. This simplifies the process of constructing an object, performing work on the object, and then returning the object from a method. It is a Ruby-ized realization of the K combinator, courtesy of Mikael Brockman.
This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here. These similar methods exist in v3.2.1: ActiveResource::Base#update_attributes Rails::Generators::ActiveModel#update_attributes ActiveRecord::Persistence#update_attributes
In a /index type listing page we can no longer assume that the list of ids coming back represents changes to all objects so we need to provide some context, that the list of object modifications in our params array is a list of modifications for some set of objects.
No documentation This method has no description. You can help the Ruby on Rails community by adding new notes. Hide source # File activerecord/lib/active_record/relation/query_methods.rb, line 80 def group (* args ) return self if args . blank? relation = clone relation . group_values...
receives a series of exception classes or class names, and a trailing :with option with the name of a method or a Proc object to be called to handle them. Alternatively a block can be given.
The Model layer represents your domain model (such as Account, Product, Person, Post ) and encapsulates the business logic that is specific to your application. In Rails, database-backed model classes are derived from ActiveRecord::Base . Active Record allows you to present the data f...
Clearing out previous values from content_for By default, content_for :thing appends whatever you put in your block to the previous value of :thing. In some cases, you’d like to clear out :thing rather than append to it. I just posted a way to do this on my blog: http://stevechanin.bl...
this has been deprecated; see linked note This has been deprecated. See this note on memoize : http://apidock.com/rails/ActiveSupport/Memoizable/memoize#1317-this-has-been-deprecated-replace-with-Memoist
# include InstanceMethods # if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type) raise "Already memoized #{symbol}" # raise "Already memoized mime_type" end # end alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type # if instance_m...
Controls tracing of assignments to global variables. The parameter +symbol_ identifies the variable (as either a string name or a symbol identifier). cmd (which may be a string or a Proc object) or block is executed whenever the variable is assigned. The block or Proc object receives ...
m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the ...
m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the ...
m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the ...