Hi to all,
I am currently learning Ruby on Rails, and I am learning from videos
from lynda.com "Ruby on Rails 3 Essential Training".
However, I have some problems when I want to assign values to my
object. I copy pasted like it is on video, but I got syntax error:
Loading development environment (Rails 3.0.10)
ruby-1.9.2-p290 :001 > second_page = Page.new ( :name=>"Second
page", :position=>1, :permalink => "second" )
SyntaxError: (irb):1: syntax error, unexpected tASSOC, expecting
'')''
...econd_page = Page.new ( :name=>"Second page", :position=>1,
...
... ^
(irb):1: syntax error, unexpected '','', expecting $end
...age.new ( :name=>"Second page", :position=>1, :permalink
=> ...
... ^
from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/
lib/rails/commands/console.rb:44:in `start''
from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/
lib/rails/commands/console.rb:8:in `start''
from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/
lib/rails/commands.rb:23:in `<top (required)>''
from script/rails:6:in `require''
from script/rails:6:in `<main>''
but if I remove () then it is ok:
ruby-1.9.2-p290 :002 > second_page = Page.new :name=>"Second
page", :position=>1, :permalink => "second"
=> #<Page id: nil, subject_id: nil, name: "Second page",
permalink:
"second", position: 1, visible: false, created_at: nil, updated_at:
nil>
ruby-1.9.2-p290 :003 >
I am wondering what is going here, what is the correct version? Did
something changed with versions?
Thank you
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 17, 4:35 pm, Dorijan Jelincic <dma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi to all, > > I am currently learning Ruby on Rails, and I am learning from videos > from lynda.com "Ruby on Rails 3 Essential Training". > However, I have some problems when I want to assign values to my > object. I copy pasted like it is on video, but I got syntax error: > > Loading development environment (Rails 3.0.10) > ruby-1.9.2-p290 :001 > second_page = Page.new ( :name=>"SecondDon''t put a space between the method name (new) and the ( Fred> page", :position=>1, :permalink => "second" ) > SyntaxError: (irb):1: syntax error, unexpected tASSOC, expecting '')'' > ...econd_page = Page.new ( :name=>"Second page", :position=>1, ... > ... ^ > (irb):1: syntax error, unexpected '','', expecting $end > ...age.new ( :name=>"Second page", :position=>1, :permalink => ... > ... ^ > from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/ > lib/rails/commands/console.rb:44:in `start'' > from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/ > lib/rails/commands/console.rb:8:in `start'' > from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/ > lib/rails/commands.rb:23:in `<top (required)>'' > from script/rails:6:in `require'' > from script/rails:6:in `<main>'' > > but if I remove () then it is ok: > > ruby-1.9.2-p290 :002 > second_page = Page.new :name=>"Second > page", :position=>1, :permalink => "second" > => #<Page id: nil, subject_id: nil, name: "Second page", permalink: > "second", position: 1, visible: false, created_at: nil, updated_at: > nil> > ruby-1.9.2-p290 :003 > > > I am wondering what is going here, what is the correct version? Did > something changed with versions? > Thank you-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > Don''t put a space between the method name (new) and the ( > > Fredthank you... that did the trick...:) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.