Gepubliceerd op: woensdag 03 september 2008 13:13:00
In blinde opruimwoede heb ik m’n huis plugins op GitHub gezet.
- ActiveForm; zie ook active_form
ruby script/plugin install git://github.com/remvee/active_form.git
- Dutchify; zie ook dutchify
ruby script/plugin install git://github.com/remvee/dutchify.git
- Labelify; Yet Another Form Builder
ruby script/plugin install git://github.com/remvee/labelify.git
- NullableBooleans; boolean attributen gemakkelijker op
nil zetten
ruby script/plugin install git://github.com/remvee/nullable_booleans.git
Published at: Monday 24 September 2007 12:49:00
Last week at RailsConf Europe I met some people who are using my ActiveForm code to make forms in their Rails sites. It’s about time to wrap it up as a plugin, so here it is.
From the README:
This plugin provides a base class for making forms with ActiveRecord validations without having a corresponding database table. You can use ActiveForm for:
- making forms which don’t needed storage, like simple email forms
- provide extra validations on existing ActiveRecord models
- make forms for composite objects
Installation:
script/plugin install http://svn.remvee.net/plugins/active_form
I know, there already is a plugin called active_form but I don’t like it. It doesn’t provide a “real” AR object causing all kinds of things to not work (like ActiveRecordHelper#form and DateHelper#datetime_select for instance), it doesn’t include any tests and my version is a lot simpler (flog score 20 versus 74).
Why not change the name? I like it! If you can come up with something better, please leave a comment.
Gepubliceerd op: woensdag 26 april 2006 09:32:00
Ik ben een simpele web applicatie met rails aan het bouwen. Niets bijzonders; wat berichtjes, een gastenboek en wat formulieren. Deze laatste formulieren hoeven niet opgeslagen te worden maar moeten verstuurd worden via e-mail. Dat versturen is geen probleem; recht toe recht aan ActiveMailer. De uitdaging zit hem in het valideren van deze formulieren.
Uitdaging is misschien een beetje sterk uitgedrukt maar als je net het beheer van berichten met ActiveRecord hebt gebouwd, is het een beetje jammer als je dan toch weer dingen gaat schrijven als:
if params[:email].nil? || !EMAIL_PATTERN.match(params[:email])
@errors[:email] = 'E-mail adres moet correct ingevuld worden.'
end
Neeh, daar pas ik voor! Ik wil gewoon form.valid? kunnen vragen zoals bij ActiveRecord objecten. Maar hoe doe je dat?
Lees verder ››