On Jan 15, 2010, at 9:31 AM, Alpha Blue wrote:
>
> Frederick Cheung wrote:
>> On Jan 15, 3:50 pm, Alpha Blue <[email protected]> wrote:
>>> Fred, so the issue with the code above is this:
>>>
>>> When using such a helper it will display:
>>>
>>> link href="/stylesheets/public/themes/default/stylesheets/default.css"
>>> media="screen" rel="stylesheet" type="text/css"
>>
>> That sounds like the path you passed didn't have a leading / (and you
>> don't want the public in there).
>>
>> Fred
>
> Fred, as always, you were correct. I removed the monkey patching code
> and then I fixed the test helper to:
>
> def current_theme_path(type)
> path = "/themes/" + @opt_default_theme + "/images/" if type == 'img'
> path = "/themes/" + @opt_default_theme + "/stylesheets/" if type ==
> 'css'
> path = "/themes/" + @opt_default_theme + "/javascripts/" if type ==
> 'js'
> path = "/themes/" + @opt_default_theme + "/swfs/" if type == 'swf'
> return path
> end
>
> ...
>
> And finally in my layout:
>
> <%= stylesheet_link_tag(current_theme_path('css')+ @opt_theme +'.css')
> %>
> <%= javascript_include_tag(current_theme_path('js')+ @opt_theme +'.js')
> %>
>
> .. and it works.
>
> I'll work with this bit of code instead and see how it affects asset
> caching.
I don't understand why you can't use a stylesheet like:
application.css
that handles the general case or "default theme", as you refer to it, and then
simply serve up a second stylesheet after that based on preference, as:
<%= stylesheet_link_tag :application %>
<%= stylesheet_link_tag @user_theme_stylesheet if @user_theme_stylesheet %>
You can then simply implement a before filter in your controller that sets
@user_theme_stylesheet based on user preference and relies on the CSS proximity
rule disambiguation to decide what CSS rule to apply.
Have I misunderstood your problem?
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.