Skip to content

Instantly share code, notes, and snippets.

@jonmanes
Created October 24, 2016 01:44
Show Gist options
  • Save jonmanes/918a4290a720c6580e392598b27c9d84 to your computer and use it in GitHub Desktop.
Save jonmanes/918a4290a720c6580e392598b27c9d84 to your computer and use it in GitHub Desktop.
bloccit-rails-console-assignment
[3] pry(main)> post = Post.first
Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
=> #<Post:0x007fadd3e56c98
id: 1,
title: "First Post",
body: "This is the first post in our system",
created_at: Mon, 24 Oct 2016 01:17:15 UTC +00:00,
updated_at: Mon, 24 Oct 2016 01:17:15 UTC +00:00>
[4] pry(main)> p post
#<Post id: 1, title: "First Post", body: "This is the first post in our system", created_at: "2016-10-24 01:17:15", updated_at: "2016-10-24 01:17:15">
=> #<Post:0x007fadd3e56c98
id: 1,
title: "First Post",
body: "This is the first post in our system",
created_at: Mon, 24 Oct 2016 01:17:15 UTC +00:00,
updated_at: Mon, 24 Oct 2016 01:17:15 UTC +00:00>
[5] pry(main)> cd post
[6] pry(#<Post>):1> self.methods.sort
=> [:!,
:!=,
:!~,
:<=>,
:==,
:===,
:=~,
:[],
:[]=,
:__binding__,
:__id__,
:__pry__,
:__send__,
:_commit_callbacks,
:_commit_callbacks=,
:_commit_callbacks?,
:_create_callbacks,
:_create_callbacks=,
:_create_callbacks?,
:_destroy,
:_destroy_callbacks,
:_destroy_callbacks=,
:_destroy_callbacks?,
:_find_callbacks,
:_find_callbacks=,
:_find_callbacks?,
:_initialize_callbacks,
:_initialize_callbacks=,
:_initialize_callbacks?,
:_read_attribute,
:_reflections,
:_reflections=,
:_reflections?,
:_rollback_callbacks,
:_rollback_callbacks=,
:_rollback_callbacks?,
:_run_commit_callbacks,
:_run_create_callbacks,
:_run_destroy_callbacks,
:_run_find_callbacks,
:_run_initialize_callbacks,
:_run_rollback_callbacks,
:_run_save_callbacks,
:_run_touch_callbacks,
:_run_update_callbacks,
:_run_validate_callbacks,
:_run_validation_callbacks,
:_save_callbacks,
:_save_callbacks=,
:_save_callbacks?,
:_touch_callbacks,
:_touch_callbacks=,
:_touch_callbacks?,
:_update_callbacks,
:_update_callbacks=,
:_update_callbacks?,
:_validate_callbacks,
:_validate_callbacks=,
:_validate_callbacks?,
:_validation_callbacks,
:_validation_callbacks=,
:_validation_callbacks?,
:_validators,
:_validators=,
:_validators?,
:`,
:acts_like?,
:actually_destroyed?,
:add_to_transaction,
:after_add_for_comments,
:after_add_for_comments=,
:after_add_for_comments?,
:after_remove_for_comments,
:after_remove_for_comments=,
:after_remove_for_comments?,
:aggregate_reflections,
:aggregate_reflections=,
:aggregate_reflections?,
:arel_attributes_with_values_for_create,
:arel_attributes_with_values_for_update,
:as_json,
:assign_attributes,
:association,
:association_cache,
:attribute_aliases,
:attribute_aliases?,
:attribute_changed?,
:attribute_changed_in_place?,
:attribute_for_inspect,
:attribute_method?,
:attribute_method_matchers,
:attribute_method_matchers?,
:attribute_missing,
:attribute_names,
:attribute_present?,
:attribute_was,
:attributes,
:attributes=,
:attributes_before_type_cast,
:attributes_changed_by_setter,
:autosave_associated_records_for_comments,
:becomes,
:becomes!,
:before_add_for_comments,
:before_add_for_comments=,
:before_add_for_comments?,
:before_remove_for_comments,
:before_remove_for_comments=,
:before_remove_for_comments?,
:blank?,
:body,
:body=,
:body?,
:body_before_type_cast,
:body_came_from_user?,
:body_change,
:body_changed?,
:body_was,
:body_will_change!,
:cache_key,
:cache_timestamp_format,
:cache_timestamp_format?,
:capture,
:changed,
:changed?,
:changed_attributes,
:changed_for_autosave?,
:changes,
:changes_applied,
:class,
:class_eval,
:clear_aggregation_cache,
:clear_association_cache,
:clear_changes_information,
:clear_destroy_state,
:clear_transaction_record_state,
:clone,
:clone_attribute_value,
:column_for_attribute,
:comment_ids,
:comment_ids=,
:comments,
:comments=,
[7] pry(#<Post>):1> nesting
Nesting status:
--
0. main (Pry top level)
1. #<Post>
[8] pry(#<Post>):1>
[9] pry(#<Post>):1> self.methods.sort
=> [:!,
:!=,
:!~,
:<=>,
:==,
:===,
:=~,
:[],
:[]=,
:__binding__,
:__id__,
:__pry__,
:__send__,
:_commit_callbacks,
:_commit_callbacks=,
:_commit_callbacks?,
:_create_callbacks,
:_create_callbacks=,
:_create_callbacks?,
:_destroy,
:_destroy_callbacks,
:_destroy_callbacks=,
:_destroy_callbacks?,
:_find_callbacks,
:_find_callbacks=,
:_find_callbacks?,
:_initialize_callbacks,
:_initialize_callbacks=,
:_initialize_callbacks?,
:_read_attribute,
:_reflections,
:_reflections=,
:_reflections?,
:_rollback_callbacks,
:_rollback_callbacks=,
:_rollback_callbacks?,
:_run_commit_callbacks,
:_run_create_callbacks,
:_run_destroy_callbacks,
:_run_find_callbacks,
:_run_initialize_callbacks,
:_run_rollback_callbacks,
:_run_save_callbacks,
:_run_touch_callbacks,
:_run_update_callbacks,
:_run_validate_callbacks,
:_run_validation_callbacks,
:_save_callbacks,
:_save_callbacks=,
:_save_callbacks?,
:_touch_callbacks,
:_touch_callbacks=,
:_touch_callbacks?,
:_update_callbacks,
:_update_callbacks=,
:_update_callbacks?,
:_validate_callbacks,
:_validate_callbacks=,
:_validate_callbacks?,
:_validation_callbacks,
:_validation_callbacks=,
:_validation_callbacks?,
:_validators,
:_validators=,
:_validators?,
:`,
:acts_like?,
:actually_destroyed?,
:add_to_transaction,
:after_add_for_comments,
:after_add_for_comments=,
:after_add_for_comments?,
:after_remove_for_comments,
:after_remove_for_comments=,
:after_remove_for_comments?,
:aggregate_reflections,
:aggregate_reflections=,
:aggregate_reflections?,
:arel_attributes_with_values_for_create,
:arel_attributes_with_values_for_update,
:as_json,
:assign_attributes,
:association,
:association_cache,
:attribute_aliases,
:attribute_aliases?,
:attribute_changed?,
:attribute_changed_in_place?,
:attribute_for_inspect,
:attribute_method?,
:attribute_method_matchers,
:attribute_method_matchers?,
:attribute_missing,
:attribute_names,
:attribute_present?,
:attribute_was,
:attributes,
:attributes=,
:attributes_before_type_cast,
:attributes_changed_by_setter,
:autosave_associated_records_for_comments,
:becomes,
:becomes!,
:before_add_for_comments,
:before_add_for_comments=,
:before_add_for_comments?,
:before_remove_for_comments,
:before_remove_for_comments=,
:before_remove_for_comments?,
:blank?,
:body,
:body=,
:body?,
:body_before_type_cast,
:body_came_from_user?,
:body_change,
:body_changed?,
:body_was,
:body_will_change!,
:cache_key,
:cache_timestamp_format,
:cache_timestamp_format?,
:capture,
:changed,
:changed?,
:changed_attributes,
:changed_for_autosave?,
:changes,
:changes_applied,
:class,
:class_eval,
:clear_aggregation_cache,
:clear_association_cache,
:clear_changes_information,
:clear_destroy_state,
:clear_transaction_record_state,
:clone,
:clone_attribute_value,
:column_for_attribute,
:comment_ids,
:comment_ids=,
:comments,
:comments=,
:committed!,
:concern,
:connection_handler,
:created_at,
:created_at=,
:created_at?,
:created_at_before_type_cast,
:created_at_came_from_user?,
:created_at_change,
:created_at_changed?,
:created_at_was,
:created_at_will_change!,
:decrement,
:decrement!,
:deep_dup,
:default_connection_handler,
:default_connection_handler?,
:default_scopes,
:default_timezone,
:define_singleton_method,
:defined_enums,
:defined_enums=,
:defined_enums?,
:delete,
:destroy,
:destroy!,
:destroyed?,
:destroyed_by_association,
:destroyed_by_association=,
:display,
:dump_schema_after_migration,
:dup,
:duplicable?,
:enable_warnings,
:encode_with,
:enum_for,
:eql?,
:equal?,
:errors,
:extend,
:find_by_statement_cache,
:find_by_statement_cache=,
:find_by_statement_cache?,
:force_clear_transaction_record_state,
:freeze,
:from_json,
:from_xml,
:frozen?,
:has_attribute?,
:hash,
:html_safe?,
:id,
:id=,
:id?,
:id_before_type_cast,
:id_came_from_user?,
:id_change,
:id_changed?,
:id_was,
:id_will_change!,
:in?,
:include_root_in_json,
:include_root_in_json=,
:include_root_in_json?,
:increment,
:increment!,
:init_with,
:initialize_internals_callback,
:inspect,
:instance_eval,
:instance_exec,
:instance_of?,
:instance_values,
:instance_variable_defined?,
:instance_variable_get,
:instance_variable_names,
:instance_variable_set,
:instance_variables,
:invalid?,
:is_a?,
:itself,
:kind_of?,
:load_dependency,
:lock!,
:lock_optimistically,
:lock_optimistically?,
:locking_enabled?,
:logger,
:mark_for_destruction,
:marked_for_destruction?,
:method,
:method_missing,
:methods,
:model_name,
:nested_attributes_options,
:nested_attributes_options?,
:new_record?,
:nil?,
:no_touching?,
:object_id,
:partial_writes,
:partial_writes?,
:perform_validations,
:persistable_attribute_names,
:persisted?,
:pluralize_table_names,
:pluralize_table_names?,
:populate_with_current_scope_attributes,
:presence,
:presence_in,
:present?,
:pretty_inspect,
:pretty_print,
:pretty_print_cycle,
:pretty_print_inspect,
:pretty_print_instance_variables,
:previous_changes,
:primary_key_prefix_type,
:private_methods,
:protected_methods,
:pry,
:psych_to_yaml,
:public_method,
:public_methods,
:public_send,
:query_attribute,
:quietly,
:quoted_id,
:raise_in_transactional_callbacks,
:raise_record_invalid,
:read_attribute,
:read_attribute_before_type_cast,
:read_attribute_for_serialization,
:read_attribute_for_validation,
:read_store_attribute,
:readonly!,
:readonly?,
:record_timestamps,
:record_timestamps=,
:record_timestamps?,
:reload,
:remember_transaction_record_state,
:remove_instance_variable,
:require_dependency,
:require_or_load,
:reset_body!,
:reset_created_at!,
:reset_id!,
:reset_title!,
:reset_updated_at!,
:respond_to?,
:respond_to_without_attributes?,
:restore_attributes,
:restore_body!,
:restore_created_at!,
:restore_id!,
:restore_title!,
:restore_transaction_record_state,
:restore_updated_at!,
:rollback_active_record_state!,
:rolledback!,
:run_callbacks,
:run_validations!,
:sanitize_for_mass_assignment,
:sanitize_forbidden_attributes,
:save,
:save!,
:schema_format,
:send,
:serializable_hash,
:silence,
:silence_stderr,
:silence_stream,
:silence_warnings,
:singleton_class,
:singleton_method,
:singleton_methods,
:skip_time_zone_conversion_for_attributes,
:skip_time_zone_conversion_for_attributes?,
:slice,
:store_full_sti_class,
:store_full_sti_class?,
:suppress,
:suppress_warnings,
:table_name_prefix,
:table_name_prefix?,
:table_name_suffix,
:table_name_suffix?,
:taint,
:tainted?,
:tap,
:time_zone_aware_attributes,
:timestamped_migrations,
:title,
:title=,
:title?,
:title_before_type_cast,
:title_came_from_user?,
:title_change,
:title_changed?,
:title_was,
:title_will_change!,
:to_enum,
:to_gid,
:to_gid_param,
:to_global_id,
:to_json,
:to_json_with_active_support_encoder,
:to_json_without_active_support_encoder,
:to_key,
:to_model,
:to_param,
:to_partial_path,
:to_query,
:to_s,
:to_sgid,
:to_sgid_param,
:to_signed_global_id,
:to_xml,
:to_yaml,
:to_yaml_properties,
:toggle,
:toggle!,
:touch,
:transaction,
:transaction_include_any_action?,
:transaction_record_state,
:trust,
:try,
:try!,
:type_for_attribute,
:unloadable,
:untaint,
:untrust,
:untrusted?,
:update,
:update!,
:update_attribute,
:update_attributes,
:update_attributes!,
:update_column,
:update_columns,
:updated_at,
:updated_at=,
:updated_at?,
:updated_at_before_type_cast,
:updated_at_came_from_user?,
:updated_at_change,
:updated_at_changed?,
:updated_at_was,
:updated_at_will_change!,
:valid?,
:validate,
:validate!,
:validate_associated_records_for_comments,
[10] pry(#<Post>):1>
[11] pry(#<Post>):1> self.update_attribute :title, "Really New Post"
(0.2ms) begin transaction
SQL (0.4ms) UPDATE "posts" SET "title" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["title", "Really New Post"], ["updated_at", "2016-10-24 01:39:12.141705"], ["id", 1]]
(0.8ms) commit transaction
=> true
[12] pry(#<Post>):1> self.update_attribute :body, "Really New Post Body"
(0.1ms) begin transaction
SQL (0.4ms) UPDATE "posts" SET "body" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["body", "Really New Post Body"], ["updated_at", "2016-10-24 01:39:31.151310"], ["id", 1]]
(4.8ms) commit transaction
=> true
[13] pry(#<Post>):1> save!
(0.1ms) begin transaction
(0.1ms) commit transaction
=> true
[14] pry(#<Post>):1> self
=> #<Post:0x007fadd3e56c98
id: 1,
title: "Really New Post",
body: "Really New Post Body",
created_at: Mon, 24 Oct 2016 01:17:15 UTC +00:00,
updated_at: Mon, 24 Oct 2016 01:39:31 UTC +00:00>
[15] pry(#<Post>):1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment