I have this form which has a whole bunch of stuff for a user to fill
out, not all of the fields have to be filled, but the one that are left
blank I need to enter a dummie value for in the database because all
that stuff gets entered later on into another form consisting of
edit_in_place fields. The way I have it now is that a method gets called
after a user profile is created and sets all the values to a dummie
string if they are blank, the problems is that there are so many field
in the table that the method is very long because of all the fields.
Bacisally I'm saying if
if @user.address.blank?
@user.address = "Empty"
Is there a way to do this which isn't as long and maybe more
programmatically correct? Thanks,
validates_each :email, :phone, :on => :create do |record, attr, value|
if value.blank? ...
end
I think you are correct and that this is exactly what I want, but it
doesn't save the values when I create a new object. I have a model for
user and am trying to save stuff on save. Here is what I got:
validates_each :company, :on => :save do|record, attr, value|
if value.blank?
attr = "Click to Edit"
end
end
I tried to say record.attr = "Click to Edit" but that didn't seem to
work. When I create a new user it seems to run through the whole process
- the validates_each too, but it doesn't save. Is there something that
I'm missing? Thanks,
Why does the value need to be in the database? Why not override the
display of the column for empty? have it output what every you want.
On Feb 8, 4:09 pm, Shandy Nantz <rails-mailing-l...@andreas-s.net>
Because later on in another part of the form I display the values in
in_place_edit fields and if the values are empty strings then I can't
edit the values by clicking on them because there is nothing to click
on.