Heroku Rails 3 app crashing - Error H10 (App crashed) - ruby-on-rails

My website works fine on my local mashine but crashes on heroku.
Here is my heroku log: http://pastie.org/private/ligfhv4tjqmodclkwxc21q
Relevant log section:
[36m2011-12-01T19:42:53+00:00 app[web.1]:←[0m
/app/.bundle/gems/ruby/1.8/gems/a
ctivesupport-3.0.3/lib/active_support/dependencies.rb:239:in
`require': /app/app /helpers/kategoris_helper.rb:2: syntax error,
unexpected kEND, expecting $end (S yntaxError)
My stack is bamboo-ree 1.8.7
I think it is to do with this helper, but are not sure:
module KategorisHelper
def sortkat(column, title = nil)
title ||= column.titleize
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "ASC" ? "DESC" : "ASC"
link_to title, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class}
end
end

Well, the error message basically means that there's an end too much (syntax error, unexpected kEND, expecting $end, a missing end is syntax error, unexpected $end, expecting kEND). ruby -c doesn't complain about your helper, did you copy the entire code?

Related

syntax error, unexpected keyword_ensure, expecting end-of-input in line 61 - haml

I am working in the following code. It is from the project 8agentball available in github (https://github.com/thinkpixellab/agent8ball).
I am a beginner in Ruby and Rails(started learning today), and I get an error when I try to execute it. I searched in the internet for over 4 hours and did not find anything.
- uncompiled = Rails.env == 'development' && params.has_key?('uncompiled')
- content_for :header do
= game_js(uncompiled)
%link{:rel => 'canonical', :href => 'http://agent8ball.com'}
%a#fork_me{:href => "https://github.com/thinkpixellab/agent8ball"}
%img{:alt => "Fork me on GitHub", :src => "http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"}
- if Rails.env == 'development'
- if(uncompiled)
= link_to "Uncompiled", root_path, :id => 'debug', :title => 'Go to compiled version'
- else
= link_to "Compiled", '/?uncompiled', :id => 'debug', :title => 'Go to uncompiled version'
And I get this error:
Showing
/Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml
where line #xx raised:
/Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml:xx: syntax error, unexpected keyword_ensure, expecting end-of-input
I tried indenting code, tried putting - end after if/else and/or do but to no use.
Any idea?
Thank you

Ruby default values error

I was reading the source code of a gem "activerecord-postgres-earthdistance".
While running the migration script, it threw an error on the following method
def order_by_distance lat, lng, order: "ASC"
It gave an error for order: "ASC"
syntax error, unexpected tLABEL
Isn't this valid Ruby syntax?
Ruby 2.0 supports keywords arguments
[5] pry(main)> def bar(a: "name", b: "fem"); puts a,b end
[6] pry(main)> bar(a: "John", b: "Male")
John
Male
[7] pry(main)> bar("John", "Male")
ArgumentError: wrong number of arguments (2 for 0)
from (pry):5:in `bar'
However the above is not valid in 1.9 see below:
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
[2] pry(main)> def bar(a: "name", b: "fem"); puts a,b end
SyntaxError: unexpected ',', expecting $end
def bar(a: "name", b: "fem"); puts a,b end
^
[2] pry(main)> def bar(a: "name"); puts a end
SyntaxError: unexpected ')', expecting $end
def bar(a: "name"); puts a end
^
For better understanding you can read here and here
def order_by_distance(lat, lng, hash={})
puts hash[:order]
end
=> order_by_distance(lat, lng, order: "ASC")
=> "ASC"
use hash arguments in ruby

Array syntax in JSON in rails 3 on Heroku

I have the following controller code:
def index
#profiles = Profile.where("(first_name || ' ' || last_name) ILIKE ?", "%#{params[:q]}%")
#autolist = []
#profiles.each do |profile|
user = User.find_by_id(profile.user_id)
#autolist.concat([{"id",profile.id,"name",profile.first_name+" "+profile.last_name,"email",user.email}])
end
respond_to do |format|
format.html # index.html.erb
format.json { render :json => #autolist }
end
end
It works in my local environment, but crashes my app. Specifically this line: #autolist.concat([{"id",profile.id,"name",profile.first_name+" "+profile.last_name,"email",user.email}])
Any ideas?
I have a feeling it has to do with my local env using ruby 1.8.7 and the heroku app running 1.9.2
This works in 1.8.7:
>> h = {"id", 6}
=> {"id"=>6}
but not in 1.9.2:
>> h = {"id",6}
SyntaxError: (irb):4: syntax error, unexpected ',', expecting tASSOC
h = {"id",6}
^
from /Users/mu/Developer/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
The rocket notation will serve you better:
#autolist.concat([{ "id" => profile.id, "name" => profile.first_name + " " + profile.last_name, "email" => user.email}])
I can't find any mention of this change in the 1.9.1 or 1.9.2 release notes and this is actually the first time I've seen the {'a', b} syntax for a Ruby Hash. Perhaps that notation was a deprecated feature that finally went away.
BTW, developing on 1.8.7 and deploying on 1.9.2 isn't the best idea.

Rails collection_select raising errors when deployed but not under development. Why?

I'm deploying a new Rails app to Heroku. This is the first time I've used Rails 3.1 with Heroku's Cedar server. I've never had so much trouble deploying an app!
First Ruby version problems, then asset precompilation errors, then gem and Procfile issues!
Now, all of the select form fields in my app appear to be generating errors. The app worked perfectly on a localhost, and I can't work out what the problem is here.
An extract from the tail:
2011-12-08T10:35:00+00:00 app[web.1]: ActionView::Template::Error (/app/app/views/gears/_panel_dataentry.html.erb:23: syntax error, unexpected ',', expecting ')'
2011-12-08T10:35:00+00:00 app[web.1]: ...nd= ( collection_select (:gear, :gear_category_id, GearCateg...
2011-12-08T10:35:00+00:00 app[web.1]: ... ^
2011-12-08T10:35:00+00:00 app[web.1]: /app/app/views/gears/_panel_dataentry.html.erb:23: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
2011-12-08T10:35:00+00:00 app[web.1]: ..._id, GearCategory.default, :id, :name, :prompt => 'Please se...
2011-12-08T10:35:00+00:00 app[web.1]: ... ^
2011-12-08T10:35:00+00:00 app[web.1]: /app/app/views/gears/_panel_dataentry.html.erb:23: syntax error, unexpected ')', expecting keyword_end
2011-12-08T10:35:00+00:00 app[web.1]: ...rompt => 'Please select...' ) );#output_buffer.safe_concat('...
2011-12-08T10:35:00+00:00 app[web.1]: 24: </tr>
2011-12-08T10:35:00+00:00 app[web.1]: 25: <tr>
This kind of error is occurring for every select field in the app.
The underlying code looks like:
<th><%= f.label :gear_category, "Category" %></th>
<td><%= collection_select (:gear, :gear_category_id, GearCategory.default, :id, :name, :prompt => 'Please select...' ) %></td>
Has this syntax changed in the latest version of Rails? Has anyone else encountered this issue? I'd appreciate any pointers or ideas!
Remove spaces between collection_select and (.

Syntax errors in html file

Not exactly sure what the errors are indicating. I am getting the following syntax errors:
compile error
app/views/students/student_fail.html.haml:33: syntax error, unexpected tIDENTIFIER, expecting ')'
... :student_fail_attribute params[:StudentFailState.true], pa...
^
app/views/students/student_fail.html.haml:33: syntax error, unexpected ')', expecting '='
...method], params[:text_method])
^
app/views/students/student_fail.html.haml:39: syntax error, unexpected kENSURE, expecting kEND
...\n", -2, false);_erbout;ensure;#haml_buffer = #haml_buffer.u...
^
app/views/students/student_fail.html.haml:40: syntax error, unexpected kENSURE, expecting kEND
app/views/students/student_fail.html.haml:42: syntax error, unexpected $end, expecting kEND
Here's the html:
:ruby
fields = if #step == 1
[ select_tag(:id, options_from_collection_for_select(Student.passed, :id, :selector_label, #student.id), :size => 10) ]
elsif #step == 2
form_for #student do |f| f.collection_select( :student_fail_attribute params[:StudentFailState.true], params[:value_method], params[:text_method])
end
#fields << render_sequence_nav(sequence_info, students_path)
fields << render(:partial => "resources_partials/sequence/nav", :locals => sequence_info.merge({:cancel_url => {:controller => :dashboard}}))
= render_form { fields }
Thanks for any response.
I think you are missing a comma between :student_fail_attribute and params[:StudentFailState.true].
You might want to think if params[:StudentFailState.true] is supposed to be there at all, unless it returns the collection you will most likely not get the expected results.

Resources