# Change default values

**URL:** <https://www.ruby-forum.com/t/change-default-values/104023>\
**Category:** Radiant CMS\
**Created:** [May 13, 2007, 2:20am UTC](https://www.ruby-forum.com/t/change-default-values/104023 "2007-05-13T02:20:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francesco\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@Francesco\_L](https://www.ruby-forum.com/u/Francesco_L)\
**Post date:** [May 13, 2007, 2:20am UTC](https://www.ruby-forum.com/t/change-default-values/104023/1 "2007-05-13T02:20:38Z")

</div>

I need to change the default values inserted by radiant in published\_at  
column.  
In the old version of Radiant I created sites with all controllers,  
models etc in the site so I modified them to avoid that the default  
values was inserted in the db.  
But now I migrated to the new version of Radiant 0.6.1 and all the code  
of Radiant is in the gem. How can I ovewrite the default functionality  
and insert my values in published\_at column?  
Thanks in advance

–  
Francesco L.  
Ymir s.r.l.  
Viale Verona 190/11  
38100 Trento

---

<div class="post-metadata">

**Author:** ![Francesco\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@Francesco\_L](https://www.ruby-forum.com/u/Francesco_L)\
**Post date:** [May 15, 2007, 1:42am UTC](https://www.ruby-forum.com/t/change-default-values/104023/2 "2007-05-15T01:42:36Z")

</div>

Francesco L. wrote:

> In the old version of Radiant I created sites with all controllers,  
> models etc in the site so I modified them to avoid that the default  
> values was inserted in the db.  
> But now I migrated to the new version of Radiant 0.6.1 and all the code  
> of Radiant is in the gem. How can I ovewrite the default functionality  
> and insert my values in published\_at column?

Can you use the console?

$ script/console productionLoading production environment.

> > page = Page.find\_by\_url(‘/’)  
> > =\> #\<Page:0x365b8fc @parent=, @attributes={“virtual”=\>“0”, …  
> > page.published\_at = Date.parse(‘1/1/2000’)  
> > =\> #\<Date: 4903089/2,0,2299161\>  
> > page.save!  
> > =\> true

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Francesco\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@Francesco\_L](https://www.ruby-forum.com/u/Francesco_L)\
**Post date:** [May 15, 2007, 12:27pm UTC](https://www.ruby-forum.com/t/change-default-values/104023/3 "2007-05-15T12:27:59Z")

</div>

John W. Long ha scritto:

> Can you use the console?

Yes I can use console but what I nedd is a little different.  
I know that I am perverting the nature of Radiant, but I am trying to  
adapt it to the needs of my silly customers. (Why customers are quite  
always silly?)  
I created a form and a script that parse the form and insert it in the  
radiant structure adding correct page parts etc.  
The customer need to upload press releases, the page is made with  
different parts: title, description, link (to a pdf tha is upload in  
the form) date.  
Every time the customer compile the form I need to insert a date written  
by the customer that could be different form the actual date.  
I changed the code in the gem, but I would prefer to do a cleaner job  
becasue changing the gem changes every radiant site on the same machine.  
(Fortunately I have only one site for the moment)

–  
Francesco L.  
Ymir s.r.l.  
Viale Verona 190/11  
38100 Trento

---

<div class="post-metadata">

**Author:** ![Francesco\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@Francesco\_L](https://www.ruby-forum.com/u/Francesco_L)\
**Post date:** [May 15, 2007, 5:20pm UTC](https://www.ruby-forum.com/t/change-default-values/104023/4 "2007-05-15T17:20:20Z")

</div>

Francesco L. wrote:

> by the customer that could be different form the actual date.  
> I changed the code in the gem, but I would prefer to do a cleaner job  
> becasue changing the gem changes every radiant site on the same machine.  
> (Fortunately I have only one site for the moment)

You could probably create what you need with an extension.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Francesco\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@Francesco\_L](https://www.ruby-forum.com/u/Francesco_L)\
**Post date:** [May 15, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/change-default-values/104023/5 "2007-05-15T16:12:12Z")

</div>

On May 15, 2007, at 5:25 AM, Francesco L. wrote:

> I changed the code in the gem, but I would prefer to do a cleaner job  
> becasue changing the gem changes every radiant site on the same  
> machine.  
> (Fortunately I have only one site for the moment)

While it’s still a little ugly, you’d probably be better off freezing  
radiant to that one site and hacking it there. That way your gem is  
still pristine and can be updated as needed without breaking your  
changes. Just run rake radiant:freeze:gems (I think) and it will  
unpack your gem (as it currently stands) into the vendor directory.  
You can then reinstall a pristine copy of the radiant gem for other  
sites.

Of course, the only truly clean way of doing it would be through an  
extension, but the above could be done quickly.

Matt
