开发者

Creating a second form page for a has_many relationship

开发者 https://www.devze.com 2022-12-27 01:56 出处:网络
I have an Organization model that has_many users through affiliations. And, in the form of the organization ( the standard edit ) I use semanting_form_for and semantic_fields_for to display the organ

I have an Organization model that has_many users through affiliations.

And, in the form of the organization ( the standard edit ) I use semanting_form_for and semantic_fields_for to display the organization fields and affiliations fields.

But I wish to create a sep开发者_如何学Carete form just to handle the affiliations of a specific organization. I was trying to go to the Organization controller and create a an edit_team and update_team methods then on the routes create those pages, but it's getting a mess and not working.

am I on the right track?


Yes, you should create edit_team and update_team methods in controller and add them into routes.rb

#organizations_controller
def edit_team
  @organization = Organization.find(params[:id])
  @team = @organization.affiliations
end

def update_team
  # updating affiliations
end

#routes.rb
map.resources :organizations, :member => { :edit_team => :get, :update_team => :put }

and this is enough. So show errors why it isn't working.

0

精彩评论

暂无评论...
验证码 换一张
取 消