it-ebooks - Rails 102
Here you can read online it-ebooks - Rails 102 full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2016, publisher: iBooker it-ebooks, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:
Romance novel
Science fiction
Adventure
Detective
Science
History
Home and family
Prose
Art
Politics
Computer
Non-fiction
Religion
Business
Children
Humor
Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.
Rails 102: summary, description and annotation
We offer to read an annotation, description, summary or preface (depends on what the author of the book "Rails 102" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.
Rails 102 — read online for free the complete book (whole text) full work
Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Rails 102" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.
Font size:
Interval:
Bookmark:
MVC(Model)(View)(Controller)RailsMVC
MVC
Ruby on RailsRailsRubyWebMVC
- Don't Repeat Yourself
- Convention Over Configuration
http://zh.wikipedia.org/wiki/Ruby_on_Rails
Ruby1993224Ruby199512fjRubyPerlPerl6pearlRuby7ruby
RubyPerlPythonRubyRuby2000Ruby
2004RoRRubyRuby2006TIOBE
http://zh.wikipedia.org/wiki/Ruby
Ruby Coding Style
array = [ "A" , "B" , "C" , "D" ] # better array = %w(A B C D)
:symbool
"string"
Hash key
# bad { "foo" => "bar" } # good { :foo => "bar" }
"string"
Ruby key string object
"string"
:
string1 = { "foo" => "bar" }string2 = { "foo" => "rab" }string1.each_key {|key| puts key.object_id.to_s} # => 2191071500 string2.each_key {|key| puts key.object_id.to_s} # => 2191041700
:symbol
:
string1 = { :foo => "bar" }string2 = { :foo => "rab" }string1.each_key {|key| puts key.object_id.to_s} # => 304828 string2.each_key {|key| puts key.object_id.to_s} # => 304828
[:symbol]
"string"
Hash key case object
Asset Pipeline (minify) (compress) Javascript / CSS CoffeeScript / SASS / ERB assets
(assets stylesheets / javascripts / images )
Yahoo Best Practices for Speeding Up Your Web Site
- Minimize HTTP Requests
- Use a CDN
- Split Components Across Domains
- Gzip Components
- Minify JavaScript and CSS
- CSS Sprites
Rails
stylesheets_include_tag "aaa" , "bbb" , :cache => true %> javascrupt_link_tag "ccc" , "ddd" , :cache => "customized-functions" %>
HTTP requests
config/enviroments/production.rb
config.asset_host = "cdn%d.example.org"
- http://cdn0.example.org
- http://cdn1.example.org
- http://cdn2.example.org
- http://cdn3.example.org
CSS Bootstrap prototyping CSS JavaScript 1MB size
Rails
(trim / uglify / gzip)
:
- / (trim)
- ( uglify )
- gz
Rails asset query string invalid browser cache
image_tag( "example.gif" ) %>
< img src = "/example.gif?1234567" />
query string assets deploy assets query string browser URI
CDN query string
stylesheets images query string
background : url (" logo-bg .gif ");
CSS CDN query string deploy CDN panel invalid assets browser
Rails 3.1 Asset Pipeline
- Fingerprinting Assets
Asset SCSS / Compass / CoffeeScript Rails
Ruby begin-end block rescue
begin # code rescue AExceptionClass => some_variable # AExceptionClass run code rescue BExceptionClass => some_other_variable # BExceptionClass run code else # run code ensure # run code end
http://www.ruby-doc.org/core-2.1.2/Exception.html
def foo # rescue # end
rails save!
, create!
save
create
boolean save!
create!
ActiveRecord::RecordInvalid
ActiveRecord::RecordInvalid
begin complex_operation_that_calls_save!_internallyrescue ActiveRecord::RecordInvalid => invalid puts invalid.record.errorsend
Blockruby code{}
def block_test puts "test start" yield puts "test done" end block_test{ puts "block working here!" } # => "test start" # => "block working here!" # => "test done"
blockblock_test
blockyield
do....end
block
@people .each do |person| puts person.name end
&& || and / or bug and or if / else boolean and / or
- foo = ( 42 && foo ) / 2
foo = && foo / => NoMethodError : undefined method '/' for nil: NilClass
food = and foo / =>
next if widget = widgets.pop
widget = widgets.pop and next
raise "Not ready!" unless ready_to_rock?
ready_to_rock? or raise "Not ready!"
- Avdi Using and and or in Ruby
# def find_book(author,title, options={}) # .... end # def word_count # .... end
# link_to( "Back" , post_path(post)) # redirect_to post_path(post)
# if post.content_size > # .... end # if (post.content.size > ) && post.is_promotion? # .... end
Ruby (space)(parentheses) Ruby parsing
Ruby super super()
class Foo def initialize(*args) args.each {|arg| puts arg} end end class Bar < Foo def initialize( a, b, c) super end end
> a, b, c = * %W[a b c] > Bar .new a, b, c
a
b
c
class Foo def initialize(*args) args.each {|arg| puts arg} end end class Bar < Foo def initialize( a, b, c) super () end end
> a, b, c = * %W[a b c] > Bar .new a, b, c
builders Template Handler erb erb HTML js buildererb HTML jshandler builder XMLRSSAtom handler
Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object named xml is automatically made available to templates with a .builder extension.
more programmatic alternative to ERB generate XML file tag
app/views/topics/show.xml.builder
xml.topic do |t| t.title @topic.title t.content @topic.contentend
xml
< topic > < title > Topic Title </<span class="hljs-title">title >
< content > Topic Content Here </<span class="hljs-title">content > </<span class="hljs-title">topic > jbuilder JSON
RSSAtom XML RSS ATOM XML Build XML RSS Tag rss version tag channel tag
app/views/topics/index.rss.builder
xml.instruct! :xml, :version => "1.0"xml.rss :version => "2.0" do xml.channel do xml.title "Rails102" xml.description "Intermediate to Rails" xml.link root_url for topic in @topics xml.item do xml.title topic.title xml.description topic.content xml.pubDate topic.created_at.to_s(:rfc822) xml.link board_topic_url(topic.board_id, topic) xml.guid board_topic_url(topic.board_id, topic) end end endend
Font size:
Interval:
Bookmark:
Similar books «Rails 102»
Look at similar books to Rails 102. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.
Discussion, reviews of the book Rails 102 and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.