Forum: Ruby on Rails Problem with updating model

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0c0eb2ade20576ec0905f35600c652bc?d=identicon&s=25 Alex (Guest)
on 2006-01-21 01:19
I trying to update DATE type field in MySQL but such errors occurs

errors:
    password_confirmation:
      - "can't be blank"
    birthday:
      - "can't be blank"

Spending hours on that, I cann't find the reason

But I've filled "login" "password" "password_confirmation" and
"birthday" fields right.
Also I want password field to be blank, not 40 digit hashed password,
but all others fields to be as they are (retrieved from database table
by ActiveRecord)
So, what's the problem with updating the "birthday" record, and how to
make the password field to be blank?
Thanks a lot.



== template
<%= start_form_tag :action=> "edit" %>
  <%= hidden_field "post", "id", :value => @edituser.id %>
  <%= text_field "edituser", 'login', :size => 30 %>
  <%= password_field "edituser", 'password', :size => 30 %>
  <%= password_field "edituser", 'password_confirmation', :size => 30 %>
  <%= date_select("edituser", 'birthday', :order => [:day, :month,
:year], :start_year => 1931, :end_year => 2001) %>
<%= end_form_tag %>

== controller
def edit
  @edituser = User.find_first(["id = ?",params[:id]])
  if @request.post?
    if not @edituser.nil?
      @edituser.login = @params[:edituser][:login]
      @edituser.birthday = @params[:edituser][:birthday]
      @edituser.login = @params[:edituser][:login]
      if not @params[:edituser][:password].nil? and
        @params[:edituser][:password] ==
@params[:edituser][:password_confirmation] and
  	@params[:edituser][:password] != ""
  	@edituser.password = @params[:edituser][:password]
      end
    end
  end
end

== model user
attr_accessor             :password_confirmation
validates_confirmation_of :password
validates_presence_of     :login, :password, :password_confirmation,
:birthday

== MySQL table users
id       int
login    varchar(40)
password varchar(40)
birthday DATE
This topic is locked and can not be replied to.