Ruby on Rails Friday, March 9, 2018

If I go to rails console

I can't get a create_table statement onto one line

irb(main):019:0> ActiveRecord::Migration.create_table :wers { |t| t.string :name }
SyntaxError: (irb):19: syntax error, unexpected '{', expecting end-of-input
Migration.create_table :wers { |t| t.string :name }



I can see this works

irb(main):032:0> 5.times do |r|
irb(main):033:1* puts "a"
irb(main):034:1> end

and this works

irb(main):031:0> 5.times { |r| puts "a"}


And I can see this works

irb(main):039:0> ActiveRecord::Migration.create_table :haae do |t|
irb(main):040:1* t.string :firstname
irb(main):041:1> end
-- create_table(:haae)
   (4.0ms)  CREATE TABLE "haae" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "firstname" varchar)
   -> 0.0057s
=> []
irb(main):042:0>


But I still can't get that create_table line onto one line


irb(main):019:0> ActiveRecord::Migration.create_table :wers { |t| t.string :name }
SyntaxError: (irb):19: syntax error, unexpected '{', expecting end-of-input
Migration.create_table :wers { |t| t.string :name }
                
I was able to replace the do and end on the 5.times line.. with {..}  and put it on one line, but I can't get the same to work for create_table 

I'm ok with putting it on multiple lines but I like the flexibility of being able to put it on one line should I so wish

Thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c0a8e0c3-8640-4574-899a-2eed0a0102f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment