« scriptのヘルプ | トップページ | テスト駆動開発 »

rubo on rails の深い世界

まず手始めは、Helperをいろいろ調べて試してみるのと ActiveRecordのメソッドを一通りおさえることからはじめましょうか。

[ ActiveRecord メソッド一覧 ]

==
===
=~
[]
[]=
__id__
__send__
`
after_create
after_destroy
after_save
after_update
after_validation
after_validation_on_create
after_validation_on_update
allow_concurrency
attribute_names
attribute_present?
attributes
attributes=
attributes_before_type_cast
attributes_from_column_definition
attributes_from_column_definition_with_lock
b64encode
before_create
before_destroy
before_save
before_update
before_validation
before_validation_on_create
before_validation_on_update
blank?
body
body?
class
clear_aggregation_cache
clear_association_cache
clone
colorize_logging
column_for_attribute
configurations
connection
copy_instance_variables_from
create
create_or_update
create_or_update_with_callbacks
create_with_callbacks
create_with_timestamps
create_without_timestamps
created_at
created_at?
daemonize
dclone
decode64
decode_b
decrement
decrement!
default_timezone
destroy
destroy_with_callbacks
destroy_with_transactions
destroy_without_callbacks
destroy_without_transactions
display
dup
email
email?
enable_warnings
encode64
eql?
equal?
errors
extend
extend_with_included_modules_from
extended_by
freeze
frozen?
gem
generate_read_methods
has_attribute?
hash
homepage
homepage?
id
id=
id?
id_before_type_cast
increment
increment!
initialize
initialize_with_callbacks
inspect
instance_eval
instance_exec
instance_of?
instance_values
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
kind_of?
load
lock!
lock_optimistically
locking_enabled?
logger
method
methods
name
name?
new_record?
nil?
object_id
pluralize_table_names
primary_key_prefix_type
private_methods
protected_methods
public_methods
quote
quote_with_deprecation
quoted_id
readonly!
readonly?
record_timestamps
reload
remove_subclasses_of
require
require_gem
require_library_or_gem
respond_to?
respond_to_without_attributes?
returning
save
save!
save_with_transactions
save_with_transactions!
save_with_validation
save_with_validation!
save_without_transactions
save_without_transactions!
save_without_validation
save_without_validation!
schema_format
send
silence_stderr
silence_stream
silence_warnings
singleton_methods
subclasses_of
suppress
table_name_prefix
table_name_suffix
taguri
taguri=
taint
tainted?
title
title?
to_a
to_json
to_param
to_s
to_xml
to_yaml
to_yaml_properties
to_yaml_style
toggle
toggle!
transaction
type
unloadable
untaint
update
update_attribute
update_attribute_with_validation_skipping
update_attribute_without_validation_skipping
update_attributes
update_attributes!
update_with_callbacks
update_with_lock
update_with_timestamps
update_without_callbacks
update_without_timestamps
valid?
valid_with_callbacks?
valid_without_callbacks?
validate
validate_on_create
validate_on_update
verification_timeout
with_options

出し方:

ruby script/console

c = new.[モデルクラス]

c.methods.sort.each do |t|

  puts t

end

[ Helper 一覧 ]

>> y ActionView::Helpers.constants
---
- JavaScriptElementCollectionProxy
- AssetTagHelper
- PaginationHelper
- TextHelper
- JavaScriptHelper
- TagHelper
- InstanceTag
- FormBuilder
- JavaScriptElementProxy
- CaptureHelper
- JavaScriptMacrosHelper
- UrlHelper
- DebugHelper
- DateHelper
- FormHelper
- JavascriptHelper
- FormOptionsHelper
- FormTagHelper
- JavaScriptVariableProxy
- CacheHelper
- ScriptaculousHelper
- PrototypeHelper
- JavaScriptCollectionProxy
- ActiveRecordHelper
- JavaScriptProxy
- BenchmarkHelper
- NumberHelper

>> y ActionView::Helpers::JavaScriptHelper.instance_methods
---
- evaluate_remote_response
- update_element_function_with_deprecation
- escape_javascript
- options_for_javascript
- define_javascript_functions
- remote_function
- observe_field
- method_option_to_s
- submit_to_remote
- update_page_tag
- javascript_cdata_section
- form_remote_tag
- observe_form
- button_to_function
- link_to_remote
- options_for_ajax
- form_remote_for
- update_page
- javascript_tag
- build_observer
- build_callbacks
- update_element_function_without_deprecation
- array_or_string_for_javascript
- remote_form_for
- update_element_function
- periodically_call_remote
- link_to_function

>> y ActionView::Helpers::TagHelper.instance_methods
---
- tag
- content_tag
- escape_once
- cdata_section

>> y ActionView::Helpers::InstanceTag.instance_methods
---
- country_options_for_select
- select_hour
- to_date_select_tag_without_error_wrapping
- content_tag
- methods
- taguri
- to_text_area_tag
- time_select
- silence_stream
- taint
- instance_variable_defined?
- taguri=
- distance_of_time_in_words
- select_minute
- method_name
- to_datetime_select_tag_without_error_wrapping
- to_yaml
- __id__
- silence_warnings
- singleton_methods
- option_groups_from_collection_for_select
- to_date_select_tag
- datetime_select
- to_date_tag
- load
- respond_to?
- to_country_select_tag
- nil?
- extend_with_included_modules_from
- to_time_select_tag_without_error_wrapping
- select_second
- to_param
- __send__
- protected_methods
- tainted?
- to_datetime_select_tag
- select_datetime
- require
- untaint
- time_zone_select
- instance_of?
- suppress
- select_day
- method
- equal?
- instance_values
- time_zone_options_for_select
- to_select_tag
- value
- private_methods
- hash
- decode64
- `
- encode64
- send
- to_time_select_tag
- to_tag
- remove_subclasses_of
- kind_of?
- freeze
- unloadable
- eql?
- instance_exec
- object_id
- id
- object
- error_message
- collection_select
- public_methods
- instance_eval
- to_boolean_select_tag
- require_gem
- decode_b
- is_a?
- require_library_or_gem
- select_month
- to_time_zone_select_tag
- value_before_type_cast
- returning
- type
- daemonize
- tag
- select_year
- instance_variables
- dclone
- tag_without_error_wrapping
- frozen?
- select_date
- cdata_section
- to_a
- to_check_box_tag
- options_for_select
- subclasses_of
- column_type
- gem
- time_ago_in_words
- with_options
- blank?
- class
- instance_variable_get
- extended_by
- select
- error_wrapping
- ==
- select_time
- ===
- escape_once
- to_s
- extend
- distance_of_time_in_words_to_now
- to_yaml_style
- to_collection_select_tag
- enable_warnings
- clone
- object_name
- =~
- instance_variable_set
- copy_instance_variables_from
- b64encode
- content_tag_without_error_wrapping
- to_content_tag
- to_radio_button_tag
- options_from_collection_for_select
- inspect
- date_select
- to_yaml_properties
- to_input_field_tag
- to_json
- display
- country_select
- silence_stderr
- dup

>> y ActionView::Helpers::FormBuilder.instance_methods
---
- fields_for
- select
- inspect
- returning
- decode_b
- password_field
- blank?
- time_select
- clone
- silence_warnings
- collection_select
- public_methods
- display
- daemonize
- instance_variable_defined?
- to_param
- equal?
- freeze
- subclasses_of
- methods
- with_options
- respond_to?
- hidden_field
- datetime_select
- dup
- instance_variables
- to_yaml_style
- __id__
- method
- eql?
- extend_with_included_modules_from
- require_gem
- object_name
- object
- to_yaml
- id
- suppress
- send
- singleton_methods
- text_area
- field_helpers
- object_name=
- load
- object=
- taint
- extended_by
- instance_variable_get
- frozen?
- field_helpers=
- text_field
- instance_of?
- __send__
- enable_warnings
- to_yaml_properties
- to_a
- encode64
- instance_values
- time_zone_select
- `
- type
- file_field
- object_id
- instance_eval
- protected_methods
- to_json
- b64encode
- radio_button
- unloadable
- check_box
- ==
- require
- ===
- copy_instance_variables_from
- instance_variable_set
- options
- extend
- kind_of?
- silence_stderr
- remove_subclasses_of
- taguri
- to_s
- instance_exec
- decode64
- date_select
- options=
- gem
- class
- hash
- require_library_or_gem
- taguri=
- private_methods
- =~
- tainted?
- untaint
- nil?
- dclone
- country_select
- is_a?
- silence_stream

>> y ActionView::Helpers::JavaScriptElementProxy.instance_methods
---
- "[]="
- decode_b
- __id__
- replace_html
- reload
- __send__
- encode64
- instance_eval
- b64encode
- decode64
- replace
- "[]"

名前から、なんとなく想像できるものと、まったくできないものがありますね。

ちなみに、動作の確認は、console の self インスタンスから、helper メソッドを使えば呼び出すことができます。

>> helper.tag :a
=> "<a />"

こんな感じです。

« scriptのヘルプ | トップページ | テスト駆動開発 »

コメント

コメントを書く

コメントは記事投稿者が公開するまで表示されません。

(ウェブ上には掲載しません)

トラックバック

この記事のトラックバックURL:
http://app.f.cocolog-nifty.com/t/trackback/437240/7305550

この記事へのトラックバック一覧です: rubo on rails の深い世界:

« scriptのヘルプ | トップページ | テスト駆動開発 »