Set Field Default Values

0 views
Skip to first unread message

Novack

unread,
Jun 14, 2009, 10:24:28 PM6/14/09
to Streamlined
Streamlined is just awesome, thanks for all the work you put into
this!
Although I understand this list, and the whole project is passing
through tough times, I will try asking anyway :)

*Anyone knows if there is a way to set a field's default value?*

And yes, I know Rails offer default values on the migrations, but
thats dependant on database engine. For instance, afaik, at least
MySQL doesnt allow default values on text/blob fields, and thats
precisely my problem.

I dont care about the default values beeing on the View layer, because
they are like "template" values anyway.


Any ideas?

Kerry

unread,
Jun 15, 2009, 11:37:42 PM6/15/09
to Streamlined
If you don't care about seeing them in the view you can just set them
using one of the rails callbacks such as before_create, before_save,
etc. See the rails api docs.
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

If you want to see the values in the view you can use the
default_value_for plugin
http://blog.phusion.nl/2008/10/03/47/

Regards,
Kerry

Novack

unread,
Jun 15, 2009, 11:53:57 PM6/15/09
to Streamlined
Thank you very much for taking your time to answer Kerry.

When I said I dont mind if its on the view, I was referring myself to
the fact that the default values shouldn't be on the view for design
correctness, but I DO need them to show in the view.

My path goes to the plugin then, which would have never be my option,
as I thought another view addon could break the Streamlined mechanics.

So, you really helped me out, thanks again!
Cheers!

Marcos.-

Reply all
Reply to author
Forward
0 new messages