For those that missed out joining the amazing turnout of ~70 people here
in
Vancouver for the mini-workshop I did on the 27th last month, I am
making
available the 30 slides I used for the presentation.
The slides were used in conjunction with me demonstrating it via command
line. Alot was learned by both attendees, and quite possibly even more
so by
myself while teaching the material.
I created the slides in a tutorial style, so although it helps if I were
to
guide you along, I really do try to do that within the slides
themselves. Be
warned, they are definately not the Takahashi style
When you run script/server and Rails gives the message
“Rails application started on http://0.0.0.0:3000/”
it is being a bit misleading. The server is serving on port 3000, and
the “0.0.0.0” means “on all network interfaces”.
A client should use a specific IP address, like 127.0.0.1.
The fact that some browsers work with 0.0.0.0 (and DHH uses this in his
screencast) just adds to the confusion.
One of the major missing areas of the mini-workshop was that of Ruby
itself.
Which I plan to cover in greater detail for the next full day workshop
on
the 1st.
There is something wrong with the code on slide 14:
class Article < ActiveRecord::Base
def author_full_name
author_first_name + " " author_last_name
end
end
I’m getting a syntax error and not sure why but in radrails , the last
e in author_last_name is highligthed.
from console:
a=Article.new
SyntaxError: ./script/…/config/…/config/…/app/models/article.rb:4:
parse error, unexpected tIDENTIFIER, expecting kEND
from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in load' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:inload’ from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in require_or_load' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:independ_on’
from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in require_dependency' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:inconst_missing’
from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing’
from (irb):1
a = Article.new
NameError: uninitialized constant Article from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in const_missing' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:inconst_missing’
Fixed the bug with the missing “+” sign, but am unsure on what your
dependencie error is all about. From what I can see it almost looks as
if
the model “Article” isn’t being loaded for some reason.
Wonder if this is some wierd error with windows? Any chance you can
check
your code into a public SVN repository so I can review it? Or even, you
can
send me a TGZ of the whole Rails directory an email it off-list to nshb
(at)
inimit dot com
Hmm… is it “article.rb” or “Article.rb” ? I wonder if that makes a
difference.
You shouldn’t have to define it manually in the console. It should load
the
class automatically for you. My guess is your case is incorrect with the
filename as you mentioned, which would cascade an error like this.
Where you create the definition for the full name method - I was short
an “end”.
However in this part, and I have gone beyond this slide yet:
In order to do this:
Loading development environment.
a = Article.new
=> #<Article:0x244301c @attributes={“author_last_name”=>nil,
“body”=>nil, “title”=>nil, “author_first_name”=>nil},
@new_record=true>
a.author_first_name = ‘Nathaniel’
=> “Nathaniel”
a.author_last_name = ‘Brown’
=> “Brown”
a.author_full_name
=> "Nathaniel B.
What I have found with script / console is I still need to define the
class and methods in console, otherwise I get an error. This is even
though it’s all in Article.rb. So I’m not sure if something is wrong
with my console or if that is just the way it works.
So, I’ll continue on and let you know if I run into any other snags.
Stuart
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.