On 11/10/2011 6:46 PM, Colin Law wrote:
On 10 November 2011 11:46, Siva Prasad<newror.u...@gmail.com> wrote:
Gurus,
Ok, I got chance to rework on it today.As Colin suggested i debugged the
code with the ruby debugger. Below is the details explained.
Controllers:
site_controller.rb
------------------------------------
def new
@site=site.new
@site.users.build
end
def create
@site=site.new([:params])
debugger
###### code i have added #######
@site.users (using debugger i did p @site.users it prints the
usertable with values i have given in form but role = nil because i dont
take role value in form)
@test=@site.users
@test.role='admin' (using debugger i did p @site.users it prints the
@test is an array of users, I don't understand how you can do
@test.role='admin'. I would have expected it to produce an error.
usertable with values along with role as admin) But DB is not updated.
##############################
end
You don't appear to have saved anything to the database.
Colin
Colin,
Thanks for your valuable inputs.
if I do @site.users.role (this throws me an error) but not @test.role
does not
Can you let me know below
1) how go about adding a role ot user object . coz I have given
resource.role='sitadmin' in the user controller (which is
registartion_controller)
2) I am doing @site.save ( which I thought would save the data to
database) If i needed to do explicitly can you pls let me know
--Siva
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.