Skip to content

Instantly share code, notes, and snippets.

@MrJaba
Created January 27, 2011 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrJaba/798740 to your computer and use it in GitHub Desktop.
Save MrJaba/798740 to your computer and use it in GitHub Desktop.
class Plan
include Mongoid::Document
embeds_many :monthly_plans
end
class MonthlyPlan
include Mongoid::Document
embeds_many :planning_options
embedded_in :plan, :inverse_of => :monthly_plans
end
class PlanningOption
include Mongoid::Document
embedded_in :monthly_plan, :inverse_of => :planning_options
end
def update
plan = Plan.find(params[:plan_id])
monthly_plan = plan.monthly_plans.find(params[:monthly_plan_id].to_i)
planning_option = monthly_plan.planning_options.find(params[:id].to_i)
planning_option.update_attributes!(params[:planning_option])
respond_to do |format|
format.js { render :nothing => true}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment