-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding presenters for question/support pages
Replacing hack that generated the questions/supports pages with presenters. View now delegates all logic to presenters. Which presenter is used is determined by controller.
- Loading branch information
Showing
5 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class QuestionPresenter | ||
include Rails.application.routes.url_helpers | ||
|
||
def initialize(q) | ||
@question = q | ||
end | ||
|
||
def resource_path(question) | ||
if question | ||
question_path(question) | ||
else | ||
question_path(@question) | ||
end | ||
end | ||
|
||
def new_resource_path | ||
new_question_path | ||
end | ||
|
||
def collection_path | ||
questions_path | ||
end | ||
|
||
def edit_resource_path | ||
edit_question_path | ||
end | ||
|
||
def apply_scope(chain) | ||
chain.no_supports | ||
end | ||
|
||
def answers_path | ||
question_answer_path(@question) | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class SupportPresenter | ||
include Rails.application.routes.url_helpers | ||
|
||
def initialize(sq) | ||
@support_question = sq | ||
end | ||
|
||
def page_title | ||
"Support Questions" | ||
end | ||
|
||
def new_resource_path | ||
new_support_question_path | ||
end | ||
|
||
def collection_path | ||
support_questions_path | ||
end | ||
|
||
def edit_resource_path | ||
edit_support_question_path | ||
end | ||
|
||
def resource_path(question) | ||
if question | ||
support_question_path(question) | ||
else | ||
support_question_path(@question) | ||
end | ||
end | ||
|
||
def apply_scope(chain) | ||
chain.supports | ||
end | ||
end |
This file contains 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
This file contains 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