Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# app/models
class User < ActiveRecord::Base
has_many :responses, dependent: :destroy
end
class Response < ActiveRecord::Base
has_one :report
has_many :points
belongs_to :user
end
class Report < ActiveRecord::Base
belongs_to :response
end
class Point < ActiveRecord::Base
belongs_to :response
end
# config/routes.rb
resources :users do
resources :responses do
resources :action_plans
end
end
# app/controllers/action_plans_controller.rb
class ActionPlansController < ApplicationController
before_filter :response
def new
@report = @response.build_report
5.times do
@response.points.build
end
end
private
def response
@response = current_user.responses.find(params[:id])
end
end
# http://localhost:3000/users/{:user_id}/responses/{:id}/action_plans/new
# Throws undefined method `committed?' for Response Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment