Created
December 8, 2014 13:47
-
-
Save puneetpandey/bafd8d78087d8713da79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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