my project works like this the user will sign up first.after sign up
he/she will edit his profile.I use restful authentication plugins for
sign up.
model
class User < ActiveRecord::Base
has_one :profile
end
class Profile < ActiveRecord::Base
belongs_to :user
end
user controller
def create
cookies.delete :auth_token
@user = User.new(params[:user])
@user.save
@profile = Profile.new
@profile.user_id = @user.id
@profile.save
end
def edit
@user = User.find(params[:id])
end
migration
class AddProfileTable < ActiveRecord::Migration
def self.up
create_table :profiles do |t|
t.string :lastname
t.string :firstname
t.integer :user_id
end
end
def self.down
remove_table :profiles
end
end
edit form
<h1>Editing user</h1>
<%= error_messages_for :user %>
<% form_for(@user) do |f| %>
<p>
<b>Name</b><br />
<%= f.text_field :login %>
</p>
<p>
<b>Email</b><br />
<%= f.text_field :email %>
</p>
<p>
<%= f.submit "Update" %>
</p>
<% end %>
my problem, how to add the lastname and firstname on the form and update
the model profile?and what the method update?
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---