• Complain

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.

it-ebooks Rails 102
  • Book:
    Rails 102
  • Author:
  • Publisher:
    iBooker it-ebooks
  • Genre:
  • Year:
    2016
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

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.

it-ebooks: author's other books


Who wrote Rails 102? Find out the surname, the name of the author of the book and a list of all author's works by series.

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.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Chapter 1 - MVC
Chapter1 - MVC

MVC(Model)(View)(Controller)RailsMVC

MVC

MVC
Chapter 2 - Rails
Chapter 2 - Rails
Ruby on Rails

Ruby on RailsRailsRubyWebMVC

Rails
  1. Don't Repeat Yourself
  2. Convention Over Configuration

http://zh.wikipedia.org/wiki/Ruby_on_Rails

Chapter 3 - Ruby
Chapter3 - Ruby

Ruby1993224Ruby199512fjRubyPerlPerl6pearlRuby7ruby

RubyPerlPythonRubyRuby2000Ruby

2004RoRRubyRuby2006TIOBE

http://zh.wikipedia.org/wiki/Ruby

Chapter 4 - Ruby
Ruby

Ruby Coding Style

Table of Contents
Array
Array %w
array = [ "A" , "B" , "C" , "D" ] # better array = %w(A B C D)
Hash

: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
Asset Pipeline

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

Minimize HTTP Requests
stylesheets_include_tag "aaa" , "bbb" , :cache => true %> javascrupt_link_tag "ccc" , "ddd" , :cache => "customized-functions" %>

HTTP requests

Use a CDN + Split Components Across Domains

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
CDN invalid cache

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

Fast by Default

Rails 3.1 Asset Pipeline

  • Fingerprinting Assets

Asset SCSS / Compass / CoffeeScript Rails

begin rescue
begin rescue

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

rails save!, create!savecreate boolean save!create!ActiveRecord::RecordInvalid

ActiveRecord::RecordInvalid

begin complex_operation_that_calls_save!_internallyrescue ActiveRecord::RecordInvalid => invalid puts invalid.record.errorsend
block
block

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_testblockyield

do....endblock

@people .each do |person| puts person.name end
&& || and or

&& || and / or bug and or if / else boolean and / or

  • foo = ( 42 && foo ) / 2
foo = && foo / => NoMethodError : undefined method '/' for nil: NilClass
and
food = and foo / =>
and or
and
next if widget = widgets.popwidget = widgets.pop and next
or
raise "Not ready!" unless ready_to_rock?ready_to_rock? or raise "Not ready!"
  • Avdi Using and and or in Ruby
method
# def find_book(author,title, options={}) # .... end # def word_count # .... end
method statement command
# link_to( "Back" , post_path(post)) # redirect_to post_path(post)
statement
# if post.content_size > # .... end # if (post.content.size > ) && post.is_promotion? # .... end

Ruby (space)(parentheses) Ruby parsing

super super()

Ruby super 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

abc

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
builders
builders

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 >
JSON builder

jbuilder JSON

RSS Builder

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
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

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.


Reviews about «Rails 102»

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.