Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The form in the view: (edit_profile.rhtml)
- <% form_for :user do |f| -%>
- <p> Email Address: </p>
- <%= f.text_field :email %>
- <p> City: </p>
- <%= f.text_field :city %>
- <p> Country: </p>
- <%= f.text_field :country %>
- <p> Postal Code: </p>
- <%= f.text_field :postal %>
- <p> Username: </p>
- <%= f.text_field :login %>
- <p> Password: </p>
- <%= f.password_field :password %>
- <p> Re-enter Password </p>
- <%= f.password_field :password_confirmation %>
- <p> Select Photo: (175x175) </p>
- <%= file_column_field "user", :icon %>
- <p> First Name: </p>
- <%= f.text_field :first_name %>
- <p> Last Name: </p>
- <%= f.text_field :last_name %>
- <p> Comments: </p>
- <%= f.text_area(:comments, "cols" => 35, "rows" => 6) %>
- <%= image_submit_tag '/images/update-now-button.jpg', :class => "register-now", :border => "0" %>
- My controller: (account_controller.rb)
- def edit_profile
- @user = User.find(params[:id])
- end
- def update_profile
- @user = User.find(params[:id])
- if @user.update_attributes(params[:user])
- flash[:notice] = 'Profile was successfully updated.'
- redirect_to :controller => 'user', :action => 'home', :id => @user
- else
- render :action => 'edit_profile'
- end
- end
- Logs:
- Parameters: {"user"=>{"city"=>"", "postal"=>"", "comments"=>"sdfasdfasdf", "icon"=>"", "password_confirmation"=>"", "country"=>"", "icon_temp"=>"", "first_name"=>"test", "login"=>"test", "password"=>"", "last_name"=>"test", "email"=>"test@test.com"}, "x"=>"42", "y"=>"18", "action"=>"edit_profile", "id"=>"1", "controller"=>"account"}
- @users.inspect reports:
- {"salt"=>"59c214e787404998ee05c27ed3b142d2cc1d4d41", "postal"=>nil, "city"=>nil, "updated_at"=>Wed Jan 31 13:35:20 0700 2007, "crypted_password"=>"990d1e6b8cc925ce4687c3e4e4986105d7a1476e", "comments"=>nil, "icon"=>nil, "remember_token_expires_at"=>nil, "country"=>nil, "id"=>1, "gender"=>"male", "remember_token"=>nil, "first_name"=>"test", "login"=>"test", "last_name"=>"test", "birth"=>1975, "email"=>"test@test.com", "created_at"=>Wed Jan 31 13:35:04 0700 2007}
- params[:user].inspect reports:
- {"city"=>"", "postal"=>"", "comments"=>"sdfasdfasdf", "icon"=>"", "password_confirmation"=>"", "country"=>"", "icon_temp"=>"", "first_name"=>"test", "login"=>"test", "password"=>"", "last_name"=>"test", "email"=>"test@test.com"}
- However, my controller code "if @user.update_attributes(params[:user])" is not updating the database.. Do these hashes have to be intentical? any idea what im missing?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement