=== Sandbox ===
Można uruchomić konsolę w trybie //Sanbox//, zapobiegając zapisaniu się jakichkolwiek zmian.
rails c --sandbox
=== pry ===
Zamiast standardowego irb, możemy w railsowej konsoli korzystać z pry.
# Gemfile
group :development do
gem 'pry-rails'
end
Dzięki temu możemy eksplorować railsy!
Mareks-Mac-mini:DeviseLdap sqbell$ rails c
Loading development environment (Rails 3.2.11)
[1] pry(main)> cd String
[2] pry(String):1> ls
constants: NON_WHITESPACE_REGEXP
Object.methods: yaml_tag
JSON::Ext::Generator::GeneratorMethods::String::Extend#methods: json_create
String.methods: try_convert
String#methods:
% clear from replace sum
* codepoints getbyte reverse swapcase
+ concat gsub reverse! swapcase!
<< constantize gsub! rindex tableize
<=> count hash rjust titlecase
== crypt hex rpartition titleize
=== dasherize html_safe rstrip to
=~ deconstantize humanize rstrip! to_blob
[] delete include? safe_constantize to_c
[]= delete! index scan to_d
acts_like_string? demodulize inquiry setbyte to_date
as_json downcase insert shellescape to_datetime
ascii_only? downcase! inspect shellsplit to_f
at dump intern singularize to_i
blank? each_byte is_utf8? size to_json
bytes each_char last slice to_r
bytesize each_codepoint length slice! to_s
byteslice each_line lines split to_str
camelcase empty? ljust squeeze to_sym
camelize encode lstrip squeeze! to_time
capitalize encode! lstrip! squish tr
capitalize! encode_json match squish! tr!
casecmp encoding mb_chars start_with? tr_s
center encoding_aware? next starts_with? tr_s!
chars end_with? next! strip truncate
chomp ends_with? oct strip! underscore
chomp! eql? ord strip_heredoc unpack
chop exclude? parameterize sub upcase
chop! first partition sub! upcase!
chr force_encoding pluralize succ upto
classify foreign_key prepend succ! valid_encoding?
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
[4] pry(String):1> show-method String#camelize
From: /Users/sqbell/.rvm/gems/ruby-1.9.3-p362/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb @ line 78:
Owner: String
Visibility: public
Number of lines: 6
def camelize(first_letter = :upper)
case first_letter
when :upper then ActiveSupport::Inflector.camelize(self, true)
when :lower then ActiveSupport::Inflector.camelize(self, false)
end
end
== Pomocy! ==
[5] pry(String):1> ? String#camelize
From: /Users/sqbell/.rvm/gems/ruby-1.9.3-p362/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb @ line 69:
Owner: String
Visibility: public
Signature: camelize(first_letter=?)
Number of lines: 9
By default, camelize converts strings to UpperCamelCase. If the argument to camelize
is set to :lower then camelize produces lowerCamelCase.
camelize will also convert '/' to '::' which is useful for converting paths to namespaces.
"active_record".camelize # => "ActiveRecord"
"active_record".camelize(:lower) # => "activeRecord"
"active_record/errors".camelize # => "ActiveRecord::Errors"
"active_record/errors".camelize(:lower) # => "activeRecord::Errors"