Friday, April 6, 2012

[Rails] I can't update data in table

In my edit page: url = profile/:id/edit

the content is !

<%= form_for(@user, :as => :user, :url => profile_path(current_user),
:html=>{:method => :put}) do |form| %>

<%= form.text_field :email, :class=>"input"%>

<%= form.submit 'Update Profile'%>

<% end %>
............................

In controller section !


class ProfileController < ApplicationController

def edit
@user = User.find(params[:id])
end

def update

@user = User.find(params[:id])

@user.email = params[:user][:email]

@user.save


respond_to do |format|

if @user.save = @user.update_attributes(params[:user])

if @user.update_attributes(params[:user])
format.html {redirect_to(profile_path(@user), :notice => 'User
was successfully updated.')}
else
format.html { render action: "index" }
end
end
end
...........

In Route ...

match "/profile/:id" => "profile#index", :as => :profile
match "/profile/:id/edit" => "profile#edit", :as => :profile_edit
put '/profile/:id' => "profile#update" ## method = put for update

...............

In Model - update data be saved in user table.

.................

But I can't update data . In rails server screen , I see the edit
process.I can't see update process - like " Update user where
.........."

Pls give me a hand!!!!!!!

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate