Without going into too much detail, is there something obvious that I''m
missing here? It seems to be finding the RJS file as expected but
generates this error:
ActionView::TemplateError (undefined local variable or method `page''
for
#<ActionView::Base:0x7f202a04>) on line #1 of
app/views/fuelings/index.js.rjs:
1: page.toggle ''fuelings''
app/views/fuelings/index.js.rjs:1:in
`_run_rjs_app47views47fuelings47index46js46rjs''
app/views/fuelings/index.js.rjs:1:in
`_run_rjs_app47views47fuelings47index46js46rjs''
app/controllers/fuelings_controller.rb:6:in `index''
The general outline (without posting too much code) is:
1) Index action in the controller has a respond_to that invokes
index.js.rjs
2) The index view has an observe that triggers when the select changes
3) The RJS renders a partial (not implemented yet)
Also set up a skeleton rails app just to test RJS and am getting the
same thing when I try any RJS tests.
=========================Controller:
class FuelingsController < ApplicationController
def index
@vehicles = Vehicle.find(:all)
@vehicle = params[:vehicle_id] ?
Vehicle.find_by_id(params[:vehicle_id]) : Vehicle.find(:first)
@fuelings = @vehicle.fuelings.paginate(:all,:per_page => 15,
:page => params[:page])
respond_to do |format|
format.html
format.js
end
end
=========================View:
<% javascript :defaults %>
<% title "Fuelings for: #{@vehicle.license}" %>
<% form_tag "", :url => fuelings_path, :method => :get do
%>
<%= select_tag
"vehicle_id",options_for_select(@vehicles.collect{|v|[v.license,v.id]},@vehicle.id)
%>
<%= observe_field("vehicle_id",
:url => { :action => :index },
:method => :get,
:with => ''vehicle_id'',
:on => "changed") %>
<% end %>
<div id="fuelings">
<%= render :partial => "fuelings" %>
</div>
<%= will_paginate @fuelings %>
=========================RJS: (just to test)
page.toggle "fuelings"
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.