Re: Custom CSS File

Hi,
Im trying to include a custom CSS file for radiant. Previously, I just
replaced the main.css file in the radiant gem directory - but thats not
“sustainable”.

I tried following Sean’s instructions below but have run into trouble.
The
technique is to create an extension that runs a before filter that
calls:
include_stylesheet ‘my_stylesheet’

But it looks like the include_stylesheet is crashing because the
@stylesheet
array is empty.

The line it is failing on is:
controllers/application.rb line 22
@stylesheets << sheet”

My extension looks like this:

def activate
require_dependency ‘application’
SiteController.class_eval do

   prepend_before_filter :customize_admin_css

   def customize_admin_css
       include_stylesheet ('radiant_custom')
  end

end
end

Any ideas anyone - could be something silly as I am still a rubynuby.

Thanks!
Topher

Following is the dev log trace:

NoMethodError (You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<):
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/app/controllers/application.rb:22:in include_stylesheet' C:/a_Systems/InstantRails-1.7-win/rails_apps/henry_radiant2/vendor/extensions/custom_stylesheet/custom_stylesheet_extension.rb:18:incustomize_admin_css’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:469:in
send' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:469:incall’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:442:in
run' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:714:inrun_before_filters’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:694:in
call_filters' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:688:inperform_action_without_benchmark’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/1.8/benchmark.rb:293:inmeasure’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/rescue.rb:83:inperform_action’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:435:in
send' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:435:inprocess_without_filters’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:684:in
process_without_session_management_support' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:inprocess’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:334:in
process' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/railties/lib/dispatcher.rb:41:indispatch’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel/rails.rb:78:in process' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel/rails.rb:76:insynchronize’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel/rails.rb:76:in process' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel.rb:618:inprocess_client’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel.rb:617:in each' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel.rb:617:inprocess_client’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel.rb:736:in run' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel.rb:736:ininitialize’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel.rb:736:in new' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel.rb:736:inrun’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel.rb:720:in initialize' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel.rb:720:innew’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel.rb:720:in run' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel/configurator.rb:271:inrun’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/lib/mongrel/configurator.rb:270:in each' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel/configurator.rb:270:inrun’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/bin/mongrel_rails:127:in run' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/lib/mongrel/command.rb:211:inrun’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
1.0.1-mswin32/bin/mongrel_rails:243
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in
load' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:inload’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in
new_constants_in' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:inload’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/railties/lib/commands/servers/mongrel.rb:60
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
require' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:innew_constants_in’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
require' C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant- 0.6.4/vendor/rails/railties/lib/commands/server.rb:39 C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
script/server:3

On Dec 2, 2007 2:02 PM, Sean C. [email protected] wrote:

   def customize_admin_css

Sean
like

perhaps level with the “Edit Page” heading, but floated to the right.

Post: [email protected]


Christopher Z.
[email protected]
604-484-9279

Oh, duh! Sorry I overlooked this problem.

You need to memoize the @stylesheets array. Change that method to look
like this:

def customize_admin_css
@stylesheets ||=[]
include_stylesheet ‘radiant_custom’
end

Sean

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs