This question is asking a similar thing: But I'm new to rail and let me apply it to my problem.
I can easily create a new collaboration between a new How can I change it: ? My models are like this: So I want to know how to create a union and how to check what I want to do Should Just An Association There is only Many thanks. You want to take a look at: AR :: B # first_or_sartay / AR :: B # First_or_initialize location and user and location:
@location = location.new ( Params [: location] .merge (: user_ids => current_user.id))
Location and association is created if
location is not present
location already exists, then a new union has been created.
location :
class space < ActiveRecord :: Base attr_accessible: name ,: user_ids has_and_belongs_to_many: user expired
user :
class user & lt; ActiveRecord :: Base attr_accessible: Email, Password: password_confirmation: remember_me has_and_belongs_to_many: end of locations
location_id and
user_id fields in my association table.
No comments:
Post a Comment