# \[ANN\] Styles 'n Scripts Extension

**URL:** <https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762>\
**Category:** Radiant CMS\
**Created:** [May 16, 2008, 1:56am UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762 "2008-05-16T01:56:11Z")\
**Posts on this page:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [May 29, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/41 "2008-05-29T21:45:41Z")

</div>

Technically, its a Radiant issue but it shows up in Extensions that  
still use ERB (or at least if your ERB templates have a

```
or

tag). That's one of the reasons I went to Haml so quickly.
If you want to know more, read my ticket here:
http://dev.radiantcms.org/ticket/642

Anyway, by moving Styles 'n Scripts templates to Haml, the issue was
bypassed. Go get 0.3.1 (or keep your Radiant at 0.6.6 to stay pre 
Haml).

-Chris
```

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [May 29, 2008, 9:32pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/42 "2008-05-29T21:32:05Z")

</div>

Has anyone else noticed their styles being kicked over to the right  
every time they save. This is crappin’ my style of stylin’. A few  
saves and man it’s off the page.

- Steven

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 15, 2008, 3:20pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/43 "2008-06-15T15:20:41Z")

</div>

For anyone (now or in the future) following this thread, I’ve identified  
the issue nurullah mentioned here. It is indeed a bug with the SnS  
extension and will be resolved in the upcoming 0.5 release.

For those interested, it’s caused by the interplay between the way SnS  
extension stores its settings, and the way Radiant rake tasks are  
performed.

SnS creates its default settings and then overwrites those with any  
custom settings during initialize.

Well, it turns out that extensions are initialized during any Rake task  
– including ‘rake db:bootstrap’ So, if you’re including SnS in a  
_brand new_ installation of Radiant (not already bootstrapped), when you  
try to create the database, the SnS extension gets initialized and tries  
to store some settings in the not-yet-created config table. Doh!

Those adding SnS to an existing Radiant install will never see this  
issue.

-Chris

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [May 29, 2008, 9:50pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/44 "2008-05-29T21:50:23Z")

</div>

Just installed .3.1 Nice job. Thanks

- Steven

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 15, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/45 "2008-06-15T16:42:48Z")

</div>

What was the fix for SnS?  
I saw the same problem with RBAC Base on a clean install (which I must  
not have tried when we created it) and haven’t had time to look into it.

-Jim

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 15, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/46 "2008-06-15T23:38:40Z")

</div>

I’m not opposed to your solution in anyway. I think it’d be helpful. I  
just think that the “right” solution for my extension would be to:

```
* have my extension's default settings installed via the initial
  migrate task
* offer a rake task to allow administrators (server admins) to
  change the css/js settings on the fly. This need only be run once
  manually (after bootstrap) and not at every init. I'd probably
  throw in a "restore_defaults" task too.

```

I designed the StylesNScripts::Config bit with the future UI designs of  
Radiant in mind – for the day when we’ll have a settings/configuration  
admin panel where extensions can add into the Radiant UI (instead of  
sticking settings in some tab or hard coded and loaded at init).

My problem is that I broke this rule and made the settings load during  
init “just for now” and shot myself in the foot. If I do what I’ve  
outlined above, it’ll be trivial to hook into Radiant’s shiny new  
settings UI when it arrives

-Chris

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 15, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/47 "2008-06-15T23:42:48Z")

</div>

I just outlined the fix in a reply to Sean’s post. It’s a little more  
elaborate (though I think more elegant) than I’d post here.

If you’re trying to get it to “just work for now” you can simply comment  
out the following line from the styles\_n\_scripts\_extension.rb file:  
include CustomSettings

Run your “rake db:bootstrap” to create the database, then un-comment  
that line back in.

-Chris

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 15, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/48 "2008-06-15T18:00:55Z")

</div>

Chris,

We might be able to make a rake task that loads the environment with no  
extensions installed. In fact, it should be as easy as something like  
this:

task :minimal\_environment do  
Radiant::Initializer.run do |config|  
config.extensions = []  
end  
end

Then we could make db:bootstrap and anything else that needs to prevent  
extensions from loading depend on that instead of the default  
:environment task.

Sean

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [August 22, 2008, 8:30pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/49 "2008-08-22T20:30:00Z")

</div>

I’m having a prob installing the rbac\_base extension. I’ve searched the  
list and found that the devs of this and another extension for radiant  
seem to have the same problem.

Following the docs:  
rake db:migrate:extensions

rake aborted!  
SQLite3::SQLException: no such table: roles: SELECT \* FROM roles

I look in …rbac\_base/db/migrate and find the appropriate migrations to  
create the needed tables. Aren’t _these_ the migrations that are trying  
to be run by db:migrate:extensions? When I browse the list archives I  
find extension devs talking amongst themselves 2 months ago about this  
problem. Since I’m new to ruby, rails, radiant and extensions this is  
_way_ over my head. Does anyone have a suggested solution? (other than  
read the code for all the above) 😉

–  
Whatever you can do, or dream you can, begin it! Boldness has genius,  
magic, and power in it. ~Goethe  
Faith makes things possible, not easy. ~Author Unknown

Burt Adsit

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [June 18, 2008, 5:33pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/50 "2008-06-18T17:33:07Z")

</div>

Sean C. wrote:

> end
> 
> Then we could make db:bootstrap and anything else that needs to  
> prevent extensions from loading depend on that instead of the default  
> :environment task.
> 
> Sean

I tried the idea above (added it to my extension – not Radiant) and set  
up my extension’s tasks like:  
task :migrate =\> :minimal\_environment do  
…

I got an error that the constant StylesNScripts wasn’t defined (at least  
that’s what I remembered).

I probably just did something wrong here but I wanted to post the result  
as an FYI.

-Chris

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [August 23, 2008, 7:33am UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/51 "2008-08-23T07:33:35Z")

</div>

Burt Adsit wrote:

> to create the needed tables. Aren’t _these_ the migrations that are  
> trying to be run by db:migrate:extensions? When I browse the list  
> archives I find extension devs talking amongst themselves 2 months ago  
> about this problem. Since I’m new to ruby, rails, radiant and  
> extensions this is _way_ over my head. Does anyone have a suggested  
> solution? (other than read the code for all the above) 😉

Hi Burt,

I may be way off here, but two questions for you:

1. Did you bootstrap the database for Radiant?
2. Any chance that your environment is different? I mean did you  
bootstrap the production database and are now doing Rake without  
specifying the environment, and therefore ending up with development  
being migrated?

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [August 23, 2008, 3:40pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/52 "2008-08-23T15:40:24Z")

</div>

On Aug 23, 2008, at 1:31 AM, Mohit S. wrote:

> > look in …rbac\_base/db/migrate and find the appropriate migrations
> 
> 1. Did you bootstrap the database for Radiant?
> 2. Any chance that your environment is different? I mean did you  
> bootstrap the production database and are now doing Rake without  
> specifying the environment, and therefore ending up with development  
> being migrated?
> 
> Cheers  
> Mohit.

Burt,

I don’t know how, but I never saw your original message, so I’m glad I  
caught Mohit’s response.

I don’t recall the exact problem, but I know that Radiant will try to  
load extensions if it hasn’t been bootstrapped. So Mohit’s first  
question is a good one. Have you bootstrapped already?

If not, move the extension up into vendor (and out of the extensions  
directory), rake db:bootstrap, then move it back and rake  
db:migrate:extensions.

We’ll be adding some other features to rbac\_base in the future, so  
please send any suggestions that you have.

RBAC was built to allow extension developers to check user roles for  
_extensions_. It does not alter roles for the normal functions of  
Radiant (pages, layouts, snippets).  
It may do that in the future. I’m personally on the fence about  
whether or not Radiant should go down the road with a complicated role  
structure in the core.

Jim G.

> **[Saturn Flyer](https://www.saturnflyer.com/)**
>
> Home info

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [August 24, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762/53 "2008-08-24T13:53:54Z")

</div>

Thanks guys, I’ll try your suggestions. I’ve been sidetracked the past  
few days installing linux/vista dual boot on my laptop. I’m finding that  
alot of developmental probs originate in the windows environment. Gotta  
do it. I’ll be running on \*nix anyway. My problems couldn’t possibly  
originate in my own ignorance. (sigh).

–  
Whatever you can do, or dream you can, begin it! Boldness has genius,  
magic, and power in it. ~Goethe  
Faith makes things possible, not easy. ~Author Unknown

Burt Adsit

[Previous page](https://www.ruby-forum.com/t/ann-styles-n-scripts-extension/137762.md?page=2)
