method
    
    id
 
  Related methods
- Class methods (218)
- 
   === ===
- 
   abstract_class? abstract_class?
- 
   accessible_attributes accessible_attributes
- 
   active_connection_name active_connection_name
- 
   add_conditions! add_conditions!  
- 
   add_group! add_group!  
- 
   add_joins! add_joins!  
- 
   add_limit! add_limit!  
- 
   add_lock! add_lock!  
- 
   add_order! add_order!  
- 
   aggregate_mapping aggregate_mapping  
- 
   all all
- 
   all_attributes_exists? all_attributes_exists?  
- 
   allow_concurrency  		
    
    
    (>= v2.2.1) allow_concurrency  		
    
    
    (>= v2.2.1)
- 
   allow_concurrency= allow_concurrency=
- 
   arel_engine  		
    
    
    (>= v3.0.0) arel_engine  		
    
    
    (>= v3.0.0)
- 
   arel_table  		
    
    
    (>= v3.0.0) arel_table  		
    
    
    (>= v3.0.0)
- 
   array_of_strings? array_of_strings? (>= v2.2.1) (>= v2.2.1)
- 
   attr_accessible attr_accessible
- 
   attribute_condition attribute_condition  
- 
   attribute_method?  		
    
    
    (>= v3.0.0) attribute_method?  		
    
    
    (>= v3.0.0)
- 
   attribute_names  		
    
    
    (>= v3.1.0) attribute_names  		
    
    
    (>= v3.1.0)
- 
   attributes_protected_by_def... attributes_protected_by_def... (>= v3.0.0) (>= v3.0.0)
- 
   attr_protected attr_protected
- 
   attr_readonly attr_readonly
- 
   base_class base_class
- 
   before_remove_const  		
    
    
    (>= v3.0.9) before_remove_const  		
    
    
    (>= v3.0.9)
- 
   benchmark benchmark
- 
   build_default_scope build_default_scope (>= v3.1.0) (>= v3.1.0)
- 
   class_name class_name
- 
   class_name_of_active_record... class_name_of_active_record...  
- 
   class_of_active_record_desc... class_of_active_record_desc...  
- 
   clear_active_connection_name clear_active_connection_name
- 
   clear_active_connections! clear_active_connections!
- 
   clear_all_cached_connections! clear_all_cached_connections!  
- 
   clear_cache! clear_cache!  
- 
   clear_connection_cache!  		
    
    
    (<= v1.0.0) clear_connection_cache!  		
    
    
    (<= v1.0.0)
- 
   clear_reloadable_connections! clear_reloadable_connections!
- 
   colorize_logging  		
    
    
    (>= v3.0.0) colorize_logging  		
    
    
    (>= v3.0.0)
- 
   colorize_logging=  		
    
    
    (>= v3.0.9) colorize_logging=  		
    
    
    (>= v3.0.9)
- 
   column_defaults  		
    
    
    (>= v3.1.0) column_defaults  		
    
    
    (>= v3.1.0)
- 
   column_methods_hash column_methods_hash
- 
   column_names column_names
- 
   columns columns
- 
   columns_hash columns_hash
- 
   compute_table_name compute_table_name (>= v3.0.0) (>= v3.0.0)
- 
   compute_type compute_type  
- 
   configurations  		
    
    
    (>= v3.0.9) configurations  		
    
    
    (>= v3.0.9)
- 
   connected? connected?
- 
   connection connection
- 
   connection= connection=
- 
   connection_config  		
    
    
    (>= v3.1.0) connection_config  		
    
    
    (>= v3.1.0)
- 
   connection_handler  		
    
    
    (>= v3.0.9) connection_handler  		
    
    
    (>= v3.0.9)
- 
   connection_id  		
    
    
    (>= v3.2.1) connection_id  		
    
    
    (>= v3.2.1)
- 
   connection_id=  		
    
    
    (>= v3.2.1) connection_id=  		
    
    
    (>= v3.2.1)
- 
   connection_pool  		
    
    
    (>= v2.2.1) connection_pool  		
    
    
    (>= v2.2.1)
- 
   construct_attributes_from_a... construct_attributes_from_a...  
- 
   construct_conditions_from_a... construct_conditions_from_a... (<= v1.1.6) (<= v1.1.6)
- 
   construct_finder_arel construct_finder_arel (>= v3.0.0) (>= v3.0.0)
- 
   construct_finder_sql construct_finder_sql  
- 
   content_columns content_columns
- 
   count  		
    
    
    (<= v1.0.0) count  		
    
    
    (<= v1.0.0)
- 
   count_by_sql count_by_sql
- 
   create create
- 
   current_scope current_scope (>= v3.1.0) (>= v3.1.0)
- 
   current_scope= current_scope= (>= v3.1.0) (>= v3.1.0)
- 
   current_scoped_methods current_scoped_methods  
- 
   decrement_counter decrement_counter
- 
   default_scope default_scope (>= v2.3.8) (>= v2.3.8)
- 
   default_select default_select (>= v2.3.8) (>= v2.3.8)
- 
   default_timezone  		
    
    
    (>= v3.0.9) default_timezone  		
    
    
    (>= v3.0.9)
- 
   define_attr_method define_attr_method  
- 
   delete delete
- 
   delete_all delete_all
- 
   descends_from_active_record? descends_from_active_record?
- 
   destroy destroy
- 
   destroy_all destroy_all
- 
   determine_deprecated_finder determine_deprecated_finder (<= v1.2.6) (<= v1.2.6)
- 
   determine_finder determine_finder  
- 
   determine_instantiator determine_instantiator  
- 
   encode_quoted_value encode_quoted_value  
- 
   establish_connection establish_connection
- 
   evaluate_default_scope evaluate_default_scope (>= v3.1.0) (>= v3.1.0)
- 
   exists? exists?
- 
   expand_attribute_names_for_... expand_attribute_names_for_...  
- 
   expand_hash_conditions_for_... expand_hash_conditions_for_...  
- 
   expand_id_conditions expand_id_conditions  
- 
   expand_range_bind_variables expand_range_bind_variables  
- 
   extract_attribute_names_fro... extract_attribute_names_fro...  
- 
   extract_options_from_args! extract_options_from_args! (<= v1.0.0) (<= v1.0.0)
- 
   find find
- 
   find_by_sql find_by_sql
- 
   finder_needs_type_condition? finder_needs_type_condition?
- 
   find_every find_every  
- 
   find_from_ids find_from_ids  
- 
   find_initial find_initial  
- 
   find_last find_last  
- 
   find_one find_one  
- 
   find_some find_some  
- 
   find_sti_class find_sti_class (>= v3.0.0) (>= v3.0.0)
- 
   first first
- 
   full_table_name_prefix  		
    
    
    (>= v2.3.8) full_table_name_prefix  		
    
    
    (>= v2.3.8)
- 
   generated_feature_methods  		
    
    
    (>= v3.2.1) generated_feature_methods  		
    
    
    (>= v3.2.1)
- 
   get_primary_key get_primary_key
- 
   human_attribute_name human_attribute_name
- 
   human_name  		
    
    
    (>= v2.2.1) human_name  		
    
    
    (>= v2.2.1)
- 
   i18n_scope  		
    
    
    (>= v3.0.0) i18n_scope  		
    
    
    (>= v3.0.0)
- 
   ignore_default_scope= ignore_default_scope= (>= v3.1.0) (>= v3.1.0)
- 
   ignore_default_scope? ignore_default_scope? (>= v3.1.0) (>= v3.1.0)
- 
   increment_counter increment_counter
- 
   inheritance_column inheritance_column
- 
   inheritance_column=  		
    
    
    (>= v3.0.9) inheritance_column=  		
    
    
    (>= v3.0.9)
- 
   inherited inherited
- 
   initialize_generated_modules  		
    
    
    (>= v3.2.1) initialize_generated_modules  		
    
    
    (>= v3.2.1)
- 
   inspect inspect
- 
   instantiate instantiate  
- 
   last last
- 
   log_connections log_connections
- 
   logger  		
    
    
    (>= v3.0.9) logger  		
    
    
    (>= v3.0.9)
- 
   lookup_ancestors  		
    
    
    (>= v3.0.0) lookup_ancestors  		
    
    
    (>= v3.0.0)
- 
   matches_dynamic_finder? matches_dynamic_finder?  
- 
   matches_dynamic_finder_with... matches_dynamic_finder_with...  
- 
   merge_conditions merge_conditions  
- 
   merge_includes merge_includes  
- 
   merge_joins merge_joins (>= v2.2.1) (>= v2.2.1)
- 
   method_missing method_missing  
- 
   mysql2_connection  		
    
    
    (>= v3.1.0) mysql2_connection  		
    
    
    (>= v3.1.0)
- 
   mysql_connection mysql_connection
- 
   new new
- 
   parse_config! parse_config! (<= v1.2.6) (<= v1.2.6)
- 
   parse_sqlite_config! parse_sqlite_config!  
- 
   pluralize_table_names  		
    
    
    (>= v3.0.9) pluralize_table_names  		
    
    
    (>= v3.0.9)
- 
   postgresql_connection postgresql_connection
- 
   primary_key primary_key
- 
   primary_key_prefix_type  		
    
    
    (>= v3.0.9) primary_key_prefix_type  		
    
    
    (>= v3.0.9)
- 
   protected_attributes protected_attributes
- 
   quote_bound_value quote_bound_value  
- 
   quoted_table_name quoted_table_name  
- 
   quote_value quote_value
- 
   raise_if_bind_arity_mismatch raise_if_bind_arity_mismatch  
- 
   read_methods  		
    
    
    (<= v1.0.0) read_methods  		
    
    
    (<= v1.0.0)
- 
   readonly_attributes readonly_attributes
- 
   relation relation (>= v3.0.0) (>= v3.0.0)
- 
   remove_connection remove_connection
- 
   remove_stale_cached_threads! remove_stale_cached_threads!  
- 
   replace_bind_variables replace_bind_variables  
- 
   replace_named_bind_variables replace_named_bind_variables  
- 
   require_mysql require_mysql
- 
   reset_column_information reset_column_information
- 
   reset_column_information_an... reset_column_information_an...
- 
   reset_counters  		
    
    
    (>= v2.3.8) reset_counters  		
    
    
    (>= v2.3.8)
- 
   reset_primary_key reset_primary_key
- 
   reset_scoped_methods reset_scoped_methods (>= v3.0.9) (>= v3.0.9)
- 
   reset_sequence_name reset_sequence_name
- 
   reset_subclasses reset_subclasses
- 
   reset_table_name reset_table_name
- 
   respond_to? respond_to?
- 
   retrieve_connection retrieve_connection
- 
   reverse_sql_order reverse_sql_order  
- 
   safe_to_array safe_to_array  
- 
   sanitize sanitize
- 
   sanitize_conditions sanitize_conditions (>= v3.0.9) (>= v3.0.9)
- 
   sanitize_sql sanitize_sql (>= v1.0.0) (>= v1.0.0)
- 
   sanitize_sql_array sanitize_sql_array  
- 
   sanitize_sql_for_assignment sanitize_sql_for_assignment  
- 
   sanitize_sql_for_conditions sanitize_sql_for_conditions  
- 
   sanitize_sql_hash sanitize_sql_hash (>= v1.2.6) (>= v1.2.6)
- 
   sanitize_sql_hash_for_assig... sanitize_sql_hash_for_assig...  
- 
   sanitize_sql_hash_for_condi... sanitize_sql_hash_for_condi...  
- 
   schema_format  		
    
    
    (>= v3.0.9) schema_format  		
    
    
    (>= v3.0.9)
- 
   scope scope  
- 
   scoped? scoped?  
- 
   scoped_methods scoped_methods (>= v1.0.0) (>= v1.0.0)
- 
   scoped_methods= scoped_methods= (<= v1.0.0) (<= v1.0.0)
- 
   self_and_descendants_from_a...  		
    
    
    (>= v2.3.8) self_and_descendants_from_a...  		
    
    
    (>= v2.3.8)
- 
   self_and_descendents_from_a...  		
    
    
    (>= v2.2.1) self_and_descendents_from_a...  		
    
    
    (>= v2.2.1)
- 
   sequence_name sequence_name
- 
   sequence_name=  		
    
    
    (>= v3.0.9) sequence_name=  		
    
    
    (>= v3.0.9)
- 
   serialize serialize
- 
   serialized_attributes serialized_attributes
- 
   set_inheritance_column set_inheritance_column
- 
   set_locking_column  		
    
    
    (<= v1.1.6) set_locking_column  		
    
    
    (<= v1.1.6)
- 
   set_primary_key set_primary_key
- 
   set_readonly_option! set_readonly_option!  
- 
   set_sequence_name set_sequence_name
- 
   set_table_name set_table_name
- 
   silence silence
- 
   single_threaded_active_conn... single_threaded_active_conn...
- 
   single_threaded_scoped_methods single_threaded_scoped_methods  
- 
   sqlite3_connection sqlite3_connection
- 
   sqlite_connection sqlite_connection
- 
   sti_name sti_name
- 
   subclasses subclasses  
- 
   symbolized_base_class  		
    
    
    (>= v3.1.0) symbolized_base_class  		
    
    
    (>= v3.1.0)
- 
   symbolized_sti_name  		
    
    
    (>= v3.1.0) symbolized_sti_name  		
    
    
    (>= v3.1.0)
- 
   table_exists? table_exists?
- 
   table_name table_name
- 
   table_name=  		
    
    
    (>= v3.0.9) table_name=  		
    
    
    (>= v3.0.9)
- 
   table_name_prefix  		
    
    
    (>= v3.0.9) table_name_prefix  		
    
    
    (>= v3.0.9)
- 
   table_name_suffix  		
    
    
    (>= v3.0.9) table_name_suffix  		
    
    
    (>= v3.0.9)
- 
   threaded_connections  		
    
    
    (<= v1.0.0) threaded_connections  		
    
    
    (<= v1.0.0)
- 
   threaded_connections=  		
    
    
    (<= v1.0.0) threaded_connections=  		
    
    
    (<= v1.0.0)
- 
   thread_safe_active_connections thread_safe_active_connections
- 
   thread_safe_scoped_methods thread_safe_scoped_methods  
- 
   timestamped_migrations  		
    
    
    (>= v3.0.9) timestamped_migrations  		
    
    
    (>= v3.0.9)
- 
   type_condition type_condition  
- 
   type_name_with_module type_name_with_module  
- 
   undecorated_table_name undecorated_table_name  
- 
   unscoped  		
    
    
    (>= v3.0.0) unscoped  		
    
    
    (>= v3.0.0)
- 
   update update
- 
   update_all update_all
- 
   update_counters update_counters
- 
   validate_find_options validate_find_options  
- 
   verification_timeout  		
    
    
    (>= v2.2.1) verification_timeout  		
    
    
    (>= v2.2.1)
- 
   verification_timeout=  		
    
    
    (>= v2.2.1) verification_timeout=  		
    
    
    (>= v2.2.1)
- 
   verify_active_connections! verify_active_connections!
- 
   with_exclusive_scope with_exclusive_scope  
- 
   with_scope with_scope  
- Instance methods (107)
- 
   <=>  		
    
    
    (>= v3.1.0) <=>  		
    
    
    (>= v3.1.0)
- 
   == ==
- 
   [] []
- 
   []= []=
- 
   arel_attributes_values arel_attributes_values (>= v3.0.0) (>= v3.0.0)
- 
   assign_attributes assign_attributes (>= v2.3.8) (>= v2.3.8)
- 
   assign_multiparameter_attri... assign_multiparameter_attri...  
- 
   attribute_for_inspect attribute_for_inspect
- 
   attribute_names attribute_names
- 
   attribute_present? attribute_present?
- 
   attributes attributes
- 
   attributes= attributes=
- 
   attributes_before_type_cast attributes_before_type_cast
- 
   attributes_from_column_defi... attributes_from_column_defi...  
- 
   attributes_protected_by_def... attributes_protected_by_def...  
- 
   attributes_with_quotes attributes_with_quotes  
- 
   becomes becomes
- 
   cache_key cache_key
- 
   clear_timestamp_attributes clear_timestamp_attributes (>= v3.1.0) (>= v3.1.0)
- 
   clone clone
- 
   clone_attributes clone_attributes  
- 
   clone_attribute_value clone_attribute_value  
- 
   column_for_attribute column_for_attribute
- 
   comma_pair_list comma_pair_list  
- 
   connection connection
- 
   convert_number_column_value convert_number_column_value  
- 
   create create  
- 
   create_or_update create_or_update  
- 
   decrement decrement
- 
   decrement! decrement!
- 
   define_question_method define_question_method (<= v1.2.6) (<= v1.2.6)
- 
   define_read_method define_read_method (<= v1.2.6) (<= v1.2.6)
- 
   define_read_method_for_seri... define_read_method_for_seri... (<= v1.2.6) (<= v1.2.6)
- 
   define_read_methods define_read_methods (<= v1.2.6) (<= v1.2.6)
- 
   delete  		
    
    
    (>= v2.2.1) delete  		
    
    
    (>= v2.2.1)
- 
   destroy destroy
- 
   destroyed?  		
    
    
    (>= v2.3.8) destroyed?  		
    
    
    (>= v2.3.8)
- 
   dup  		
    
    
    (>= v3.0.0) dup  		
    
    
    (>= v3.0.0)
- 
   encode_with  		
    
    
    (>= v3.1.0) encode_with  		
    
    
    (>= v3.1.0)
- 
   ensure_proper_type ensure_proper_type  
- 
   eql? eql?
- 
   evaluate_read_method evaluate_read_method (<= v1.2.6) (<= v1.2.6)
- 
   execute_callstack_for_multi... execute_callstack_for_multi...  
- 
   extract_callstack_for_multi... extract_callstack_for_multi...  
- 
   extract_max_param_for_multi... extract_max_param_for_multi... (>= v3.1.0) (>= v3.1.0)
- 
   find_parameter_position find_parameter_position  
- 
   freeze freeze
- 
   frozen? frozen?
- 
   has_attribute? has_attribute?
- 
   hash hash
- 
   id id
- 
   id= id=
- 
   id_before_type_cast id_before_type_cast
- 
   increment increment
- 
   increment! increment!
- 
   initialize_copy  		
    
    
    (>= v3.0.0) initialize_copy  		
    
    
    (>= v3.0.0)
- 
   initialize_dup  		
    
    
    (>= v3.1.0) initialize_dup  		
    
    
    (>= v3.1.0)
- 
   init_with  		
    
    
    (>= v3.0.9) init_with  		
    
    
    (>= v3.0.9)
- 
   inspect inspect
- 
   instantiate_time_object instantiate_time_object  
- 
   interpolate_and_sanitize_sql interpolate_and_sanitize_sql (>= v3.0.9) (>= v3.0.9)
- 
   interpolate_sanitized_sql interpolate_sanitized_sql (>= v3.0.9) (>= v3.0.9)
- 
   interpolate_sql interpolate_sql  
- 
   log_protected_attribute_rem... log_protected_attribute_rem... (>= v2.2.1) (>= v2.2.1)
- 
   mass_assignment_options mass_assignment_options (>= v3.1.0) (>= v3.1.0)
- 
   mass_assignment_role mass_assignment_role (>= v3.1.0) (>= v3.1.0)
- 
   method_missing method_missing (<= v1.2.6) (<= v1.2.6)
- 
   new_record? new_record?
- 
   object_from_yaml object_from_yaml  
- 
   populate_with_current_scope... populate_with_current_scope... (>= v3.0.9) (>= v3.0.9)
- 
   query_attribute query_attribute (<= v1.2.6) (<= v1.2.6)
- 
   quote quote (<= v1.2.6) (<= v1.2.6)
- 
   quote_columns quote_columns  
- 
   quoted_column_names quoted_column_names  
- 
   quoted_comma_pair_list quoted_comma_pair_list  
- 
   quoted_id quoted_id
- 
   quote_value quote_value  
- 
   read_attribute read_attribute (<= v1.2.6) (<= v1.2.6)
- 
   read_attribute_before_type_... read_attribute_before_type_... (<= v1.2.6) (<= v1.2.6)
- 
   read_date_parameter_value read_date_parameter_value (>= v3.1.0) (>= v3.1.0)
- 
   readonly! readonly!
- 
   readonly? readonly?
- 
   read_other_parameter_value read_other_parameter_value (>= v3.1.0) (>= v3.1.0)
- 
   read_time_parameter_value read_time_parameter_value (>= v3.1.0) (>= v3.1.0)
- 
   read_value_from_parameter read_value_from_parameter (>= v3.1.0) (>= v3.1.0)
- 
   reload reload
- 
   remove_attributes_protected... remove_attributes_protected...  
- 
   remove_readonly_attributes remove_readonly_attributes  
- 
   respond_to?  		
    
    
    (<= v1.2.6) respond_to?  		
    
    
    (<= v1.2.6)
- 
   save save
- 
   save! save!
- 
   set_serialized_attributes set_serialized_attributes (>= v3.1.0) (>= v3.1.0)
- 
   to_ary to_ary (>= v3.1.0) (>= v3.1.0)
- 
   toggle toggle
- 
   toggle! toggle!
- 
   to_param to_param
- 
   to_xml  		
    
    
    (<= v1.1.6) to_xml  		
    
    
    (<= v1.1.6)
- 
   to_yaml  		
    
    
    (>= v3.2.1) to_yaml  		
    
    
    (>= v3.2.1)
- 
   type_cast_attribute_value type_cast_attribute_value  
- 
   unserializable_attribute? unserializable_attribute? (<= v1.2.6) (<= v1.2.6)
- 
   unserialize_attribute unserialize_attribute (<= v1.2.6) (<= v1.2.6)
- 
   update update  
- 
   update_attribute update_attribute
- 
   update_attributes update_attributes
- 
   update_attributes! update_attributes!
- 
   write_attribute write_attribute (<= v1.2.6) (<= v1.2.6)
- 
   yaml_initialize  		
    
    
    (>= v3.2.1) yaml_initialize  		
    
    
    (>= v3.2.1)
     = private
 = private
     = protected
 = protected
  
id()
  public
  A model instance’s primary key is always available as model.id whether you name it the default ‘id’ or set it to something else.
    Show source    
    
      
  
# File activerecord/lib/active_record/base.rb, line 2139 def id attr_name = self.class.primary_key column = column_for_attribute(attr_name) self.class.send(:define_read_method, :id, attr_name, column) # now that the method exists, call it self.send attr_name.to_sym end

 RSpec
RSpec Ruby on Rails
Ruby on Rails Ruby
Ruby