Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
miguel.camba
committed
May 6, 2012
1 parent
cd8eeb0
commit 51dd258
Showing
4 changed files
with
38 additions
and
103 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,72 +1,42 @@ | |||
# -*- encoding : utf-8 -*- | # -*- encoding : utf-8 -*- | ||
class IssuesController < ApplicationController | class IssuesController < ApplicationController | ||
|
respond_to :html, :json | ||
def index |
|
||
@issues = Issue.all | # | ||
|
# Decent exposure | ||
respond_to do |format| | # | ||
format.html | expose(:project) { Project.find(params[:project_id]) } | ||
format.json { render json: @issues } | expose(:issues) { project.issues } | ||
end | expose(:issue) | ||
|
|||
def index | |||
respond_with issues | |||
end | end | ||
|
|
||
def show | def show | ||
@issue = Issue.find(params[:id]) | respond_with issue | ||
|
|||
respond_to do |format| | |||
format.html | |||
format.json { render json: @issue } | |||
end | |||
end | end | ||
|
|
||
def new | def new | ||
@issue = Issue.new | respond_with issue | ||
|
|||
respond_to do |format| | |||
format.html | |||
format.json { render json: @issue } | |||
end | |||
end | end | ||
|
|
||
def edit | def edit | ||
@issue = Issue.find(params[:id]) | respond_with issue | ||
end | end | ||
|
|
||
def create | def create | ||
@issue = Issue.new(params[:issue]) | issue.save | ||
|
respond_with issue | ||
respond_to do |format| | |||
if @issue.save | |||
format.html { redirect_to @issue, notice: 'Issue was successfully created.' } | |||
format.json { render json: @issue, status: :created, location: @issue } | |||
else | |||
format.html { render action: "new" } | |||
format.json { render json: @issue.errors, status: :unprocessable_entity } | |||
end | |||
end | |||
end | end | ||
|
|
||
def update | def update | ||
@issue = Issue.find(params[:id]) | issue.save | ||
|
respond_with issue | ||
respond_to do |format| | |||
if @issue.update_attributes(params[:issue]) | |||
format.html { redirect_to @issue, notice: 'Issue was successfully updated.' } | |||
format.json { head :no_content } | |||
else | |||
format.html { render action: "edit" } | |||
format.json { render json: @issue.errors, status: :unprocessable_entity } | |||
end | |||
end | |||
end | end | ||
|
|
||
def destroy | def destroy | ||
@issue = Issue.find(params[:id]) | issue.destroy | ||
@issue.destroy | respond_with issue | ||
|
|||
respond_to do |format| | |||
format.html { redirect_to issues_url } | |||
format.json { head :no_content } | |||
end | |||
end | end | ||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,72 +1,41 @@ | |||
# -*- encoding : utf-8 -*- | # -*- encoding : utf-8 -*- | ||
class ProjectsController < ApplicationController | class ProjectsController < ApplicationController | ||
|
respond_to :html, :json | ||
|
|||
# | # | ||
# Decent exposure | # Decent exposure | ||
# | # | ||
expose(:projects) { Project.all } | expose(:projects) { Project.all } | ||
expose(:project) | expose(:project) | ||
|
|
||
def index | def index | ||
respond_to do |format| | respond_with projects | ||
format.html | |||
format.json { render json: projects } | |||
end | |||
end | end | ||
|
|
||
def show | def show | ||
respond_to do |format| | respond_with project | ||
format.html | |||
format.json { render json: project } | |||
end | |||
end | end | ||
|
|
||
def new | def new | ||
respond_to do |format| | respond_with project | ||
format.html | |||
format.json { render json: project } | |||
end | |||
end | end | ||
|
|
||
def edit | def edit | ||
@project = Project.find(params[:id]) | respond_with project | ||
end | end | ||
|
|
||
def create | def create | ||
@project = Project.new(params[:project]) | project.save | ||
|
respond_with project | ||
respond_to do |format| | |||
if @project.save | |||
format.html { redirect_to @project, notice: 'Project was successfully created.' } | |||
format.json { render json: @project, status: :created, location: @project } | |||
else | |||
format.html { render action: "new" } | |||
format.json { render json: @project.errors, status: :unprocessable_entity } | |||
end | |||
end | |||
end | end | ||
|
|
||
def update | def update | ||
@project = Project.find(params[:id]) | project.save | ||
|
respond_with project | ||
respond_to do |format| | |||
if @project.update_attributes(params[:project]) | |||
format.html { redirect_to @project, notice: 'Project was successfully updated.' } | |||
format.json { head :no_content } | |||
else | |||
format.html { render action: "edit" } | |||
format.json { render json: @project.errors, status: :unprocessable_entity } | |||
end | |||
end | |||
end | end | ||
|
|
||
def destroy | def destroy | ||
@project = Project.find(params[:id]) | project.destroy | ||
@project.destroy | respond_with project | ||
|
|||
respond_to do |format| | |||
format.html { redirect_to projects_url } | |||
format.json { head :no_content } | |||
end | |||
end | end | ||
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