Rails Syntax Error Unexpected Tassoc Expecting Kend
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies ruby tassoc of this site About Us Learn more about Stack Overflow the company ruby hash Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Syntax error, unexpected tASSOC, expecting keyword_end up vote 1 down vote favorite Added the convert_options code to existing Paperclip code in my user method. Now getting: /Users/-----/----/-------/app/models/user.rb:148: syntax error, unexpected tASSOC, expecting keyword_end :convert_options => { :small => '-quality 40' } What am I missing? User Model: ... # Paperclip has_attached_file :photo, :styles => { :small => ["50x50#", :jpeg], :big => ["450x450#", :jpeg] } :convert_options => { :small => '-quality 40' } validates_attachment_size :photo, :less_than => 5.megabytes validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png'] ... ruby-on-rails syntax paperclip share|improve this question edited Jun 1 '13 at 18:39 Simone Carletti 122k24253297 asked Jun 1 '13 at 18:18 Zander Perry 49110 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted You're missing a comma after your :styles => {...}. share|improve this answer answered Jun 1 '13 at 18:28 RobHeaton 1,0351713 Awesome. Thanks Rob. –Zander Perry Jun 1 '13 at 18:37 Yes. It could help if you line up your symbols in a column. I'll just show an example down in an answer here. –Douglas G. Allen Aug 24 '14 at 19:58 add a comment| up vote 0 down vote has_attached_file :photo, :styles => { :small => ["50x50#", :jpeg], :big => ["450x450#", :jpeg] }, :convert_options => { :small => '-quality 40' } I know that it's a lot of indenting but it helps me when I try to debug some thing. Some editors highlight opening brackets with closing one
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/16875816/syntax-error-unexpected-tassoc-expecting-keyword-end mysterious ruby syntax error up vote 12 down vote favorite 1 i'm beyond confused: this is almost a copy/paste out of a RoR action mailer guide, and yet it throws a syntax error: class Contact < ActionMailer::Base def contact a_name, a_company, a_phone, a_email, a_comments subject "Contact request from #{name}" recipients "some@address.com" from "some_other@address.com" sent_on Time.now body { :name => a_name, :company => a_company, http://stackoverflow.com/questions/4540829/mysterious-ruby-syntax-error :phone => a_phone, :email => a_email, :comments => a_comments } end end the error is: app/models/contact.rb:9: syntax error, unexpected tASSOC, expecting '}' body { :name => a_name, :company => a_company... ^ app/models/contact.rb:9: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' ...{ :name => a_name, :company => a_company, :phone => a_phone,... ^ app/models/contact.rb:9: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' ...ompany => a_company, :phone => a_phone, :email => a_email, :... ^ app/models/contact.rb:9: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' ..., :phone => a_phone, :email => a_email, :comments => a_comme... ^ app/models/contact.rb:9: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' ...email => a_email, :comments => a_comments, } ^ any ideas? i can't figure out what i'm doing wrong here. ruby-on-rails ruby share|improve this question edited Aug 11 '11 at 7:54 Devin M 7,98521937 asked Dec 27 '10 at 18:22 kolosy 1,44011438 add a comment| 2 Answers 2 active oldest votes up vote 26 down vote accepted Add parentheses body({...}) to state explicitly you're doing a method call with hash argument. Otherwise, {...} is probably confused with function (or lambda, whatever
here for a quick overview of the site Help Center Detailed answers to http://stackoverflow.com/questions/10454590/rails-3-2-with-ruby-1-8-syntax-problems-unexpected-tassoc-expecting-unex any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/22511081/rails-rake-task-syntax-error-unexpected-n-expecting-tassoc policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community rails syntax Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Rails 3.2 with ruby 1.8 syntax problems ( unexpected tASSOC, expecting '}', unexpected ':', expecting kEND) up vote 0 down vote favorite I am trying to deploy a rails syntax error rails 3.2 app where the ruby version is 1.8. I could workaround a few hash syntax troubles I had, but there is still one I can't get over with: Note I hired a hosting service that won't install ruby 1.9. The error is from {app_path}/config/environment.rb:5 [ pid=586526 thr=203092280 file=utils.rb:176 time=2012-05-04 15:32:29.667 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected tASSOC, expecting '}' {app_path}/config/initializers/wrap_parameters.rb:8: warning: don't put space before argument parentheses {app_path}/config/initializers/wrap_parameters.rb:8: warning: don't put space before argument parentheses from {app_path}/config/environment.rb:5 [ pid=539635 thr=202883380 file=utils.rb:176 time=2012-05-04 14:30:21.570 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND from {app_path}/config/environment.rb:5 [ pid=539635 thr=202883380 file=utils.rb:176 time=2012-05-04 14:29:31.744 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND The file is config/initializers/wrap_parameters.rb and the content is like follows: ActiveSupport.on_load(:action_controller) do # it was originally # wrap_parameters format: [:json] # ruby 1.9 syntax # the follow line is line
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Rails Rake task: syntax error, unexpected '\n', expecting tASSOC up vote 3 down vote favorite I have this code in my rake task: variables[:hotels].push( { :id => offering.ID, :name => offering.vendor.Name, :placing_name => offering.Name, My::Media::Account.find_by_guid(offering.VendorID).photos.each do |p| :hotel_images.push({ :id => p.id, :image => p.image, :url => "http://m.website.com/uploads/photo/image/#{p.id}/#{p.image}" }) end #there is an error }) When I'm trying to run it, I'm getting an error syntax error, unexpected '\n', expecting tASSOC in Terminal. It points on last end. Where did I make a mistake? Thanks! ruby share|improve this question edited Mar 19 '14 at 15:48 meagar♦ 136k21203238 asked Mar 19 '14 at 15:44 Pavel Babin 6751926 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted You can't insert executable code there. Ruby expects to see the next key in the hash you're defining, not a blob of code. You also can't push onto a symbol that way, :hotel_images.push({ isn't ever going to work. If you want :hotel_images to map to an array, you need to move the key outside the loop, and use map instead of each: variables[:hotels].push( { :id => offering.ID, :name => offering.vendor.Name, :placing_name => offering.Name, :hotel_images => My::Media::Account.find_by_guid(offering.VendorID).photos.map