Has anyone had any luck using the CalendarHelper plugin at http://wiki.rubyonrails.com/rails/pages/CalendarHelper recently? I''m scratching my head over the following error when I look at any page in my application: NameError in CalendarController#index undefined local variable or method `date_format'' for #<CalendarController:0x24ccd4c> RAILS_ROOT: script/../config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/controllers/application.rb:8:in `localize'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:399:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:394:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:383:in `before_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:365:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in `process'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81: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'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 #{RAILS_ROOT}/app/controllers/application.rb:8:in `localize'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:399:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:394:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:383:in `before_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:365:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in `process'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81: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'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 Request Parameters: None Show session dump --- flash: !map:ActionController::Flash::FlashHash {} I''m sure this is a bad user on device error, but I would appreciate any insight. Thanks, Steve Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} -- Posted via http://www.ruby-forum.com/.
On Thursday 27 July 2006 20:42, Steve Webb wrote:> Has anyone had any luck using the CalendarHelper plugin at > http://wiki.rubyonrails.com/rails/pages/CalendarHelper recently?Did you look at an intact version of the wiki page? It was botched and I have just rolled it back to a previous. correct state. That said, as the original author of this beast, I have to admit that it is a bit unwieldy and certainly warrants to be encapsulated in a plugin. Michael -- Michael Schuerig mailto:michael@schuerig.de http://www.schuerig.de/michael/
Michael Schuerig wrote:> Did you look at an intact version of the wiki page? It was botched and I > have just rolled it back to a previous. correct state.I did get it from the wiki page. I''ve replaced that version with the one currently on the page. Unfortunatly, it doesn''t seem to have helped. My problem appears to be with date_format getting added to ActiveRecord:Base. I get the following error message: NameError in CalendarController#index undefined local variable or method `date_format'' for #<CalendarController:0x24cc98c> I''m sure this is something stupid, but I''m new to Rails, and therefor dumb.> That said, as the original author of this beast, I have to admit that it > is a bit unwieldy and certainly warrants to be encapsulated in a > plugin.I''d be happy to create the plugin encapsulation once I get this working. It will be a nice little project for me. Thanks, Steve -- Posted via http://www.ruby-forum.com/.
On Thursday 27 July 2006 22:04, Steve Webb wrote:> Michael Schuerig wrote: > > Did you look at an intact version of the wiki page? It was botched > > and I have just rolled it back to a previous. correct state. > > I did get it from the wiki page. I''ve replaced that version with the > one currently on the page. Unfortunatly, it doesn''t seem to have > helped. My problem appears to be with date_format getting added to > ActiveRecord:Base. I get the following error message: > > NameError in CalendarController#index > > undefined local variable or method `date_format'' for > #<CalendarController:0x24cc98c>Ah, yes, I see. The cause is indeed very simple: date_format is not defined anywhere. The reason is, that it is really up to your app and the localization package (if any) you''re using. If you don''t have to deal with that stuff, just do it like this class ApplicationController < ActionController::Base prepend_before_filter :localize def localize # determine locale and set other relevant stuff # ... ActiveRecord::Base.date_format = ''%Y-%m-%d'' # or ''%m/%d/Y'' or ... end end Michael -- Michael Schuerig mailto:michael@schuerig.de http://www.schuerig.de/michael/
> > def localize > # determine locale and set other relevant stuff > # ... > ActiveRecord::Base.date_format = ''%Y-%m-%d'' # or ''%m/%d/Y'' or ... > end > endThat was dumb, even for me! Thanks for the help. -- Posted via http://www.ruby-forum.com/.
Okay, next silly question. I''m trying to create a very simple index.rhtml to display a flat calendar. So far I''ve got: <%= stylesheet_link_tag ''calendar-system.css'' %> <%= javascript_include_tag ''calendar'', ''calendar-en'', ''calendar-setup'' %> <html> <h2>Calendar!</h2> <%= calendar ''person'', ''birthday'', { :class => ''date'' }, { :firstDay => 1, :range => [1920, 1990], :step => 1, :showOthers => true } %> </html> When I hit this page I get the following message: NoMethodError in Calendar#index Showing app/views/calendar/index.rhtml where line #6 raised: undefined method `calendar'' for #<#<Class:0x22ddab8>:0x22dda90> Does this mean that my page isn''t finding the the calendar method from calendar_helper.rb, or am I failing to declare something in my controller? Sorry about the newbie questions. Hopefully I will leave this phase soon. Thanks, Steve -- Posted via http://www.ruby-forum.com/.
On Thursday 27 July 2006 23:40, Steve Webb wrote:> Showing app/views/calendar/index.rhtml where line #6 raised: > > undefined method `calendar'' for #<#<Class:0x22ddab8>:0x22dda90> > > Does this mean that my page isn''t finding the the calendar method > from calendar_helper.rb, or am I failing to declare something in my > controller?Yes. Either in your application controller (app/controllers/application.rb) or in the individual controllers whose views use the calendar helper you need to include and declare the new helper methods class MyController < ApplicationController ... include BoilerPlate::Helpers::ActionHelper helper BoilerPlate::Helpers::ActionHelper ... end HTH, Michael -- Michael Schuerig mailto:michael@schuerig.de http://www.schuerig.de/michael/
I seem to be making some progress. I''ve modified my controller to: class CalendarController < ApplicationController include BoilerPlate::Helpers::ActionHelper helper BoilerPlate::Helpers::ActionHelper layout ''default'' def index end end When I hit the page, it throws an exception. I get the following message in development.log: uninitialized constant Helpers ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'' script/../config/../app/controllers/calendar_controller.rb:3 I assume this means that Helpers isn''t being correctly defined? Thanks, Steve -- Posted via http://www.ruby-forum.com/.
On Friday 28 July 2006 01:45, Steve Webb wrote:> I seem to be making some progress. I''ve modified my controller to: > > class CalendarController < ApplicationController > > include BoilerPlate::Helpers::ActionHelper > helper BoilerPlate::Helpers::ActionHelper > > layout ''default'' > > > def index > end > > end > > When I hit the page, it throws an exception. I get the following > message in development.log: > > uninitialized constant Helpers > ./script/../config/../vendor/rails/activesupport/lib/active_support/d >ependencies.rb:123:in `const_missing'' > script/../config/../app/controllers/calendar_controller.rb:3 > > I assume this means that Helpers isn''t being correctly defined?Most likely you need to require the file containing BoilerPlate::Helpers::ActionHelper. Michael -- Michael Schuerig mailto:michael@schuerig.de http://www.schuerig.de/michael/
Michael Schuerig wrote:> On Friday 28 July 2006 01:45, Steve Webb wrote: >> def index >> script/../config/../app/controllers/calendar_controller.rb:3 >> >> I assume this means that Helpers isn''t being correctly defined? > > Most likely you need to require the file containing > BoilerPlate::Helpers::ActionHelper. > > Michael > > -- > Michael Schuerig > mailto:michael@schuerig.de > http://www.schuerig.de/michael/That was the problem. Thank you so much for your help! -- Posted via http://www.ruby-forum.com/.