Edge Rails: parse error, unexpected $, expecting kEND

New to this environment and working my way through “Agile Web
Development with Rails”. I had a problem with decimal fields and am
using Edge Rails now to get around that issue - only I am now
experiencing other problems…

If you have this book, the exercise is Iteration A4: Prettier Listings

I have generated some ruby script with the command: ruby script/generate
scaffold product admin

The script produced is as follows:

class AdminController < ApplicationController
def index
list
render :action => ‘list’
end

GETs should be safe (see

URIs, Addressability, and the use of HTTP GET and POST)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }

def list
@product_pages, @products = paginate :products, :per_page => 10
end

def show
@product = Product.find(params[:id])
end

def new
@product = Product.new
end

def create
@product = Product.new(params[:product])
if @product.save
flash[:notice] = ‘Product was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

def edit
@product = Product.find(params[:id])
end

def update
@product = Product.find(params[:id])
if @product.update_attributes(params[:product])
flash[:notice] = ‘Product was successfully updated.’
redirect_to :action => ‘show’, :id => @product
else
render :action => ‘edit’
end
end

def destroy
Product.find(params[:id]).destroy
redirect_to :action => ‘list’
end
end

When this script is called (http://localhost:3000/admin the following
error is generated:

app/models/product.rb:11: parse error, unexpected $, expecting kEND
RAILS_ROOT: script/…/config/…

Application Trace | Framework Trace | Full Trace
vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in
load_without_new_constant_marking' vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in load_file’
vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in load_file’
vendor/rails/activesupport/lib/active_support/dependencies.rb:95:in
require_or_load' vendor/rails/activesupport/lib/active_support/dependencies.rb:249:in load_missing_constant’
vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in
const_missing' vendor/rails/activesupport/lib/active_support/dependencies.rb:465:in const_missing’
vendor/rails/activesupport/lib/active_support/inflector.rb:162:in
constantize' vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb:148:in constantize’
vendor/rails/actionpack/lib/action_controller/pagination.rb:195:in
paginator_and_collection_for' vendor/rails/actionpack/lib/action_controller/pagination.rb:130:in paginate’
app/controllers/admin_controller.rb:12:in list' app/controllers/admin_controller.rb:3:in index’
vendor/rails/actionpack/lib/action_controller/base.rb:1092:in
perform_action_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:632:in call_filter’
vendor/rails/actionpack/lib/action_controller/filters.rb:634:in
call_filter' vendor/rails/actionpack/lib/action_controller/filters.rb:619:in perform_action_without_benchmark’
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in measure’
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' vendor/rails/actionpack/lib/action_controller/rescue.rb:115:in perform_action’
vendor/rails/actionpack/lib/action_controller/base.rb:427:in
process_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:624:in process_without_session_management_support’
vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in
process' vendor/rails/actionpack/lib/action_controller/base.rb:330:in process’
vendor/rails/railties/lib/dispatcher.rb:39:in dispatch' vendor/rails/railties/lib/webrick_server.rb:112:in handle_dispatch’
vendor/rails/railties/lib/webrick_server.rb:78:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in start' vendor/rails/railties/lib/webrick_server.rb:62:in dispatch’
vendor/rails/railties/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in require’
vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in require’
vendor/rails/railties/lib/commands/server.rb:39
script/server:3

The error apparently means a missing “end” but i cannot see where…

Any clues?

Hi –

On Tue, 9 Jan 2007, Stephen Jones wrote:

The script produced is as follows:

class AdminController < ApplicationController
def index

When this script is called (http://localhost:3000/admin the following
error is generated:

app/models/product.rb:11: parse error, unexpected $, expecting kEND
RAILS_ROOT: script/…/config/…

It’s hard to know the problem without seeing product.rb.

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (Ruby for Rails)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

Hey Stephen, if you’re using AWDwRv2, I would recommend using rails
1.2 RC 2 to work your way through the book because it’s covering the
features of rails 1.2. Also, you should be aware that Edge is a
development branch. Thus, things may or may not work.

Good luck,

-Conrad

Stephen Jones wrote:

I did this, but rails -v still produces a version of 1.1.6.

Where else can I get Rails 1.2 RC 2 ?

That’s ok, rails -v will continue to say 1.1.6 until the official 1.2
release is out.

If you want to make sure you’ve got the right version of rails, do
this:

ruby script/about

If you see an “edge version” mentioned somewhere in the list of stats
(a number greater than 5000 or so) then you’re all set.

Jeff

Conrad T. wrote:

Hey Stephen, if you’re using AWDwRv2, I would recommend using rails
1.2 RC 2 to work your way through the book because it’s covering the
features of rails 1.2. Also, you should be aware that Edge is a
development branch. Thus, things may or may not work.

Good luck,

-Conrad

Thanks Conrad. I have resolved my problem by finding a typo and
correcting it. However I am still expecting ongoing problems with my
current Rails release.

I thought I downloaded v1.2 - the book suggests:

Download http://media.pragprog.com/titles/rails2/code/rails.zip intoyour
application’s vendor directory and unzip it. It should create a
newdirectory called rails In your application’s top-level directory,
issue the command rakerails:update

I did this, but rails -v still produces a version of 1.1.6.

Where else can I get Rails 1.2 RC 2 ?

Stephen

Where else can I get Rails 1.2 RC 2 ?

Stephen

I am not sure which version is available via the pragprog website, but
you can install the latest version on your machine using:

gem install rails --source http://gems.rubyonrails.org
–include-dependencies

Personally, I have refrained from doing that until it’s stamped 1.2
proper and froze RC2 to a development app:

rake rails:freeze:edge TAG=rel_1-2-0_RC2