apidock.com Archives - 20 September 2017, Wednesday

  • trace_var (Kernel)

    apidock.com 18 Sep '17, 1am

    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 ...

  • sleep (Kernel)

    apidock.com 09 Sep '17, 11pm

    Suspends the current thread for duration seconds (which may be any number, including a Float with fractional seconds). Returns the actual number of seconds slept (rounded), which may be less than that asked for if another thread calls Thread#run. Called without an argument,

  • to_json (ActiveRecord::Serialization)

    apidock.com 30 Jun '17, 4pm

    ActiveRecord::Base.include_root_in_json controls the top-level behavior of to_json . In a new Rails application, it is set to true in initializers/new_rails_defaults.rb. When it is true, to_json will emit a single root node named after the object’s type. For example:

  • respond_to? (Object)

    apidock.com 12 Jun '17, 1am

    Returns true if obj responds to the given method . Private methods are included in the search only if the optional second parameter evaluates to true . If the method is not implemented, as Process.fork on Windows, File.lchmod on GNU/Linux, etc., false is returned. If the method is not...

  • ActiveSupport::Subscriber

    apidock.com 30 May '17, 5pm

    ActiveSupport::Subscriber is an object set to consume ActiveSupport::Notifications . The subscriber dispatches notifications to a registered object based on its given namespace. An example would be Active Record subscriber responsible for collecting statistics about queries: module Ac...

  • mattr_accessor (Module)

    apidock.com 30 Apr '17, 4am

    If a subclass changes the value then that would also change the value for parent class. Similarly if parent class changes the value then that would change the value of subclasses too.

  • Net::HTTP

    apidock.com 28 Apr '17, 9pm

    For example, all 2XX responses are instances of a Net::HTTPSuccess subclass, a 3XX response is an instance of a Net::HTTPRedirection subclass and a 200 response is an instance of the Net::HTTPOK class. For details of response classes, see the section “HTTP Response Classes” below.

  • attachment (ActionMailer::PartContainer)

    apidock.com 06 Mar '17, 3am

    attachments and implicit multipart There is a small gotcha - this caught me up for a while. If you are using implicit multipart mime types by naming your template xxx.text.html.erb and xxx.text.plain.erb, you will need to change your template name back to the original xxx.erb. If you ...

  • is_a? (ActiveSupport::Duration)

    apidock.com 02 Mar '17, 2pm

    This method has no description. You can help the Ruby on Rails community by adding new notes.

  • source_location (Method)

    apidock.com 19 Feb '17, 4pm

    source filename and line number containing this method or nil if this method was not defined in

  • group_by (Enumerable)

    apidock.com 04 Feb '17, 1am

    * * call-seq: * enum.group_by {| obj | block } => a_hash * * Returns a hash, which keys are evaluated result from the * block, and values are arrays of elements in <i>enum<

  • assert_valid_keys (Hash)

    apidock.com 19 Dec '16, 7am

    Note that keys are treated differently than HashWithIndifferentAccess, meaning that string and symbol keys will not match.

  • ids (ActiveRecord::Calculations)

    apidock.com 15 Oct '16, 7pm

    Pluck all the ID’s for the relation using the table’s primary key Person . ids # SELECT people.id FROM people Person . joins ( :companies ). ids # SELECT people.id FROM people INNER JOIN companies ON companies.person_id = people.id Show source # File activerecord/lib/active_record/rel...

  • delete_if (Hash)

    apidock.com 26 Aug '16, 8pm

    Welcome Register Projects Help About Blog APIdock release: IRON STEVE (1.4) If you have any comments, ideas or feedback, feel free to contact us at APIdock copyright Nodeta Oy 2008-2016 Flowdock - Team Inbox With Chat for Software Developers Check out how the team behind APIdock conne...

  • to_json (Hash)

    apidock.com 15 Jul '16, 12am

    also filter down to any hash values. This is particularly useful for converting hashes containing ActiveRecord objects or any object that responds to options in their

  • create_join_table (ActiveRecord::ConnectionAdapters::SchemaStatements)

    apidock.com 24 Apr '16, 10pm

    Creates a new join table with the name created using the lexical order of the first two arguments. These arguments can be a String or a Symbol . # Creates a table called 'assemblies_parts' with no id. create_join_table ( :assemblies , :parts ) You can pass a options hash can include t...

  • forty_two (Array)

    apidock.com 11 Sep '15, 3pm

    Welcome Register Projects Help About Blog APIdock release: IRON STEVE (1.4) If you have any comments, ideas or feedback, feel free to contact us at APIdock copyright Nodeta Oy 2008-2015 Flowdock - Team Inbox With Chat for Software Developers Check out how the team behind APIdock conne...

  • html_safe (String)

    apidock.com 16 Jun '15, 8pm

    Marks a string as trusted safe. It will be inserted into HTML with no additional escaping performed. It is your responsibilty to ensure that the string contains no malicious content. This method is equivalent to the `raw` helper in views. It is recommended that you use `sanitize` inst...

  • select (ActiveRecord::QueryMethods)

    apidock.com 09 Mar '15, 10pm

    First: takes a block so it can be used just like Array#select. Model . all . select { | m | m . field == value } This will build an array of objects from the database for the scope, converting them into an array and iterating through them using Array#select. Second: Modifies the SELEC...

  • presence (Object)

    apidock.com 09 Mar '15, 3pm

    Returns the receiver if it’s present otherwise returns nil . object.presence is equivalent to object . present? ? object : nil For example, something like state = params [ :state ] if params [ :state ]. present? country = params [ :country ] if params [ :country ]. present? region = s...

  • klass (ActiveRecord::Reflection::AssociationReflection)

    apidock.com 22 Jan '15, 1pm

    Returns the target association’s class. class Author < ActiveRecord :: Base has_many :books end Author . reflect_on_association ( :books ). klass # => Book Note: Do not call klass .new or klass .create to instantiate a new association object. Use build_association or create_associatio...

  • composed_of (ActiveRecord::Aggregations::ClassMethods)

    apidock.com 21 Jan '15, 9am

    :class_name - Specifies the class name of the association. Use it only if that name can’t be inferred from the part id. So composed_of :address will by default be linked to the Address class, but if the real class name is CompanyAddress, you’ll have to specify it with this option. :ma...

  • forty_two (ActiveSupport::CoreExtensions::Array::Access)

    apidock.com 08 Jan '15, 1pm

    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 v4.1.8: Array#forty_two ActiveRecord::Associations::CollectionAssociation#forty_two ActiveRecord::Associations::CollectionProxy#forty_two A...

  • fetch (Hash)

    apidock.com 08 Jan '15, 2am

    can’t be found, there are several options: With no other arguments, it will raise an KeyError exception; if default is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned.

  • changed_for_autosave? (ActiveRecord::AutosaveAssociation)

    apidock.com 25 Dec '14, 2am

    Returns whether or not this record has been changed in any way (including whether any of its nested autosave associations are likewise changed) Show source # File activerecord/lib/active_record/autosave_association.rb, line 253 def changed_for_autosave? new_record? || changed? || mark...

  • serialize (ActiveRecord::Base)

    apidock.com 25 Oct '14, 10pm

    If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, then specify the name of that attribute using this method and it will be handled automatically. The serialization is done through YAML . If class_name is specified, the seri...

  • memoize (ActiveSupport::Memoizable)

    apidock.com 27 Sep '14, 6pm

    # 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...

  • crypt (String)

    apidock.com 02 Aug '14, 4pm

    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 ...

  • has_many (ActiveRecord::Associations::ClassMethods)

    apidock.com 27 Jul '14, 7am

    Specifies an association through which to perform the query. This can be any other type of association, including other :through associations. Options for :class_name, :primary_key and :foreign_key are ignored, as the association uses the source reflection. If the association on the j...

  • const_set (Module)

    apidock.com 03 Jul '14, 9pm

    Sets the named constant to the given object, returning that object. Creates a new constant if no constant with the given