views:

79

answers:

1

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 separete 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?

+1  A: 

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.

fl00r
I'm having a problem submiting the form.I have this routeupdate_team_organization PUT /organizations/:id/update_team(.:format) {:controller=>"organizations", :action=>"update_team"}And my form starts with :<% semantic_form_for update_team_organization_path do |f| %>The submit button should call the action update_team in the organization controller, but I get this error:(see comment below )
Victor Martins
ActionController::UnknownAction (No action responded to 1. Actions: create, current_user, current_user_session, destroy, edit, edit_team, index, logged_in?, login_required, new, redirect_to_target_or_default, show, update, and update_team):The url in the browser is:http://localhost:3000/organizations/1/edit_teamSo he is pointing at the ID and not the action, that should be, update_team.
Victor Martins
Fixed the problem with this:<% semantic_form_for @organization, :url => { :action => "update_team" } do |f| %>
Victor Martins