unexpected keyword_do_block
The following snippet works fine with my Rails 3.0.3:
class Lab1开发者_JAVA百科pd1amController < ApplicationController
def index
respond_to do |format|
@students = Student.find_by_sql("SELECT * FROM students WHERE students.session = 'AM' and students.pd1 = 'Science' ORDER BY lname ASC")
format.html # index.html.erb
format.xml { render :xml => @students }
end
end
def show
@students = Student.find(params[:all])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @student }
end
end
end
But when I deploy with using Heroku, I get the following syntax error message (on Heroku logs):
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3 .0.3/lib/active_support/dependencies.rb:239:in `require': /app/app/controllers/lab1pd1am_controller.rb:1: syntax error, unexpected keyword_do_block, expecting ';' or '\n' (SyntaxError)
I would make sure that something didn't sneak in there before you did a git push heroku master
.
It could use some cleaning up as well.
class Lab1pd1amController < ApplicationController
def index
@students = Student.where(:session => "AM", :pd1 => "Science").order("lname ASC")
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @students }
end
end
def show
@student = Student.find(params[:all])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @student }
end
end
end
You could also swap out the respond_to
's for the respond_to/respond_with
combo to clean it up a bit more.
精彩评论