wintermeyer / rails-4.2-book Goto Github PK
View Code? Open in Web Editor NEWRuby on Rails 4.2 book
Ruby on Rails 4.2 book
The following code is duplicated (around line 945):
$ rake routes
Prefix Verb URI Pattern Controller#Action
products GET /products(.:format) products#index
product GET /products/:id(.:format) products#show
Around line 55 there is the following code/output which doesn't make sense.
$ rails generate scaffold
^C^C/Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application.rb:156:in `fork': Interrupt
from /Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application.rb:156:in `serve'
from /Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application.rb:131:in `block in run'
from /Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application.rb:125:in `loop'
from /Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application.rb:125:in `run'
from /Users/xyz/.rvm/gems/ruby-2.2.0/gems/spring-1.3.4/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/xyz/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/xyz/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
MAC-00020:shop xyz$ rails generate scaffold
It seems that the command tree
is not a standard on every bash console.
MAC-00020:shop richertd$ tree app/views/products/
-bash: tree: command not found
we could use find
instead?
MAC-00020:shop richertd$ find app/views/products/
app/views/products/
app/views/products//_form.html.erb
app/views/products//edit.html.erb
app/views/products//index.html.erb
app/views/products//index.json.jbuilder
app/views/products//new.html.erb
app/views/products//show.html.erb
app/views/products//show.json.jbuilder
What do you think?
The following code in chapter06-routing.md needs to be fixed. See the screenshot.
Plus: The URLs are missing the 3000.
Please double check other chapters by browsing through https://www.gitbook.com/content/book/wintermeyer/rails-4-2-book for this kind of error too.
The pages can be accessed at the following URLs after starting the Rails
server with `rails server`:
- <http://localhost:300/home/index>
for `home_index GET /home/index(.:format)
home#index`
- <http://localhost:300/home/ping>
for `home_ping GET /home/ping(.:format)
home#ping`
- <http://localhost:300/home/pong>
for `home_pong GET /home/pong(.:format)
home#pong`
In chapter 4 one of the first examples is to create a Country
model. To proof that the model is created one has to type the model name into rails console, like so:
$> Country
My first output was: => Country (call 'Country.connection' to establish a connection)
So i searched the web and discovered that this is a feature that Rails version 4 and upwards is offering.
The connection to the database from the console is only established when needed.
To fix this, you can wether call the suggested Country.connection
or simple call a function on this model like Country.count
. After that the connection is established and the output is like expected.
My question. Should this behavior reflect in an added article to the book? Maybe a note under this example?
The chapter05-scaffolding.md should describe how one can deactivate the generating of JSON by deleting the jbuilder gem in the Gemfile.
The example should be an upgrade from Rails 4.2.0 to 4.2.1.
In chapter 3 the text says "So let's go to the URL http://localhost:3000 in the web browser." but the screenshot displays the URL http://0.0.0.0:3000. Please create a new screenshot and double check other screenshots.
Using localhost:3000
is a bit better than using 0.0.0.0:3000
. On some OSes strange side effects happen and therefor localhost:3000
is preferred.
$ grep "http://0.0.0.0:3000" chapter03-first-steps-with-rails.md
So let's go to the URL <http://0.0.0.0:3000> or <http://localhost:3000>
<http://0.0.0.0:3000/hello-world>:
> <http://0.0.0.0:3000/hello-world.html>. But Rails regards HTML and
<http://0.0.0.0:3000/example/test>:
Visit that page with the URL <http://0.0.0.0:3000/example/test>
If we now go to the URL <http://0.0.0.0:3000/example/test>, we see the 2000:
<http://0.0.0.0:3000/game/ping>? Easy, you will say, we just change the
When we try to go to <http://0.0.0.0:3000/game/ping> we are
automatically redirected to <http://0.0.0.0:3000/game/pong> and in the
Redirected to http://0.0.0.0:3000/game/pong
<http://0.0.0.0:3000/game/ping>. We are redirected from ping to pong.
<http://0.0.0.0:3000/game/ping> in the browser:
If we go to <http://0.0.0.0:3000/game/pong> we still see the normal Pong
page. But if we go to <http://0.0.0.0:3000/game/ping> we are redirected
14:46 $
Book
has to be changed to Book.column_names
. Same for other occurrences of this functionallity:
$ rails console
Loading development environment (Rails 4.2.1)
>> Book
=> Book(id: integer, title: string, created_at: datetime, updated_at: datetime)
>> Author
=> Author(id: integer, book_id: integer, first_name: string, last_name: string, created_at: datetime, updated_at: datetime)
>> exit
$
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.