This repository has been archived by the owner on Dec 23, 2019. It is now read-only.
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
1 parent
38478c4
commit 6854b0b
Showing
12 changed files
with
152 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,32 @@ | ||
class ProposalsController < ApplicationController | ||
# GET /proposals | ||
# GET /proposals.json | ||
|
||
def index | ||
@proposals = Proposal.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @proposals } | ||
end | ||
end | ||
|
||
# GET /proposals/1 | ||
# GET /proposals/1.json | ||
def show | ||
@proposal = Proposal.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @proposal } | ||
end | ||
end | ||
|
||
# GET /proposals/new | ||
# GET /proposals/new.json | ||
def new | ||
@proposal = Proposal.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @proposal } | ||
end | ||
end | ||
|
||
# GET /proposals/1/edit | ||
def edit | ||
@proposal = Proposal.find(params[:id]) | ||
end | ||
|
||
# POST /proposals | ||
# POST /proposals.json | ||
def create | ||
@proposal = Proposal.new(params[:proposal]) | ||
|
||
respond_to do |format| | ||
if @proposal.save | ||
format.html { redirect_to @proposal, notice: 'Proposal was successfully created.' } | ||
format.json { render json: @proposal, status: :created, location: @proposal } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @proposal.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /proposals/1 | ||
# PUT /proposals/1.json | ||
def update | ||
@proposal = Proposal.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @proposal.update_attributes(params[:proposal]) | ||
format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' } | ||
format.json { head :ok } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @proposal.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /proposals/1 | ||
# DELETE /proposals/1.json | ||
def destroy | ||
@proposal = Proposal.find(params[:id]) | ||
@proposal.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to proposals_url } | ||
format.json { head :ok } | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
%table | ||
- @proposal.each do |p| | ||
%tr | ||
%td | ||
%span.span_currentvote | ||
%td | ||
| ||
%td | ||
%h3 | ||
=link_to p.content, "/proposals/#{p.id}" |
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,7 @@ | ||
!= "$('ul.tabbernav').html('#{j render "shared/tabs"}').show();" | ||
- unless params[:page] | ||
!= "$('#loop_main').html('#{j render(@proposals)}').append('#{j paginate(@proposals)}');" | ||
- else | ||
!= "$('#loop_main').append('#{j render(@proposals)}').append('#{j paginate(@proposals)}');" | ||
!= if "$(#span.next).length" | ||
!= "$('.pagination').remove();" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
!= "$('ul.tabbernav').html('#{j render "shared/tabs"}');" | ||
!= "$('ul.tabbernav').hide();" | ||
!= "$('#loop_main').html('#{j render @users}');" | ||
!= "$('.tabbernav').hide()" |
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 |
---|---|---|
@@ -1,46 +1,47 @@ | ||
class String | ||
def initial | ||
self[0,1] | ||
end | ||
end | ||
|
||
class RiaGenerator < Rails::Generators::Base | ||
source_root File.expand_path('../templates', __FILE__) | ||
|
||
argument :layout_name, :type => :string, :default => "proposal" | ||
class_option :stylesheet, :type => :boolean, :default => true, :description => "Include stylesheet file" | ||
argument :name, :type => :string, :default => "proposal" | ||
#class_option :stylesheet, :type => :boolean, :default => true, :description => "Include stylesheet file" | ||
|
||
def generate_layout | ||
copy_file "stylesheet.css", "app/assets/stylesheets/#{file_name}.sass" if options.stylesheet? | ||
template "layout.html.erb", "app/#{file_name}/views/index.html.haml" | ||
template "_model.html.haml", "app/views/#{plural_name}/_#{file_name}.html.haml" | ||
template "index.js.haml", "app/views/#{plural_name}/index.js.haml" | ||
template "controller.rb", "app/controllers/#{plural_name}_controller.rb" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#copy_file "index.html.haml", "app/controllers/#{file_name}/index.html.haml" | ||
#template "layout.html.erb", "app/#{file_name}/views/index.html.haml" | ||
end | ||
|
||
private | ||
def file_name | ||
layout_name.underscore | ||
name.underscore | ||
end | ||
|
||
def plural_name | ||
name.pluralize | ||
end | ||
|
||
# invoke mongoid | ||
# create app/models/proposal.rb | ||
# invoke test_unit | ||
# create test/unit/proposal_test.rb | ||
# create test/fixtures/proposals.yml | ||
# route resources :proposals | ||
# invoke scaffold_controller | ||
# create app/controllers/proposals_controller.rb | ||
# invoke erb | ||
# create app/views/proposals | ||
# create app/views/proposals/index.html.erb | ||
# create app/views/proposals/edit.html.erb | ||
# create app/views/proposals/show.html.erb | ||
# create app/views/proposals/new.html.erb | ||
# create app/views/proposals/_form.html.erb | ||
# invoke test_unit | ||
# create test/functional/proposals_controller_test.rb | ||
# invoke helper | ||
# create app/helpers/proposals_helper.rb | ||
# invoke test_unit | ||
# create test/unit/helpers/proposals_helper_test.rb | ||
# invoke assets | ||
# invoke js | ||
# create app/assets/javascripts/proposals.js | ||
# invoke scss | ||
# create app/assets/stylesheets/proposals.css.scss | ||
# invoke scss | ||
# identical app/assets/stylesheets/scaffolds.css.scss | ||
# create app/models/proposal.rb | ||
# route resources :proposals | ||
# create app/controllers/proposals_controller.rb | ||
# create app/views/proposals | ||
# create app/views/proposals/index.html.erb | ||
# create app/views/proposals/edit.html.erb | ||
# create app/views/proposals/show.html.erb | ||
# create app/views/proposals/new.html.erb | ||
# create app/views/proposals/_form.html.erb | ||
# create app/assets/javascripts/proposals.js | ||
|
||
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,10 @@ | ||
%table | ||
- @<%= file_name %>.each do |<%= file_name.initial %>| | ||
%tr | ||
%td | ||
%span.span_currentvote | ||
%td | ||
| ||
%td | ||
%h3 | ||
=link_to <%= file_name.initial %>.content, "/<%=plural_name%>/#{<%=file_name.initial%>.id}" |
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,32 @@ | ||
class <%=plural_name.capitalize%>Controller < ApplicationController | ||
def index | ||
@<%=plural_name%> = <%=file_name.capitalize%>.all | ||
end | ||
def show | ||
@<%=plural_name%> = <%=file_name.capitalize%>.find(params[:id]) | ||
end | ||
def new | ||
@<%=plural_name%> = <%=file_name.capitalize%>.new | ||
end | ||
def edit | ||
@<%=plural_name%> = <%=file_name.capitalize%>.find(params[:id]) | ||
end | ||
def create | ||
@<%=plural_name%> = <%=file_name.capitalize%>.new(params[:proposal]) | ||
end | ||
def update | ||
@<%=plural_name%> = <%=file_name.capitalize%>.find(params[:id]) | ||
end | ||
def destroy | ||
@<%=plural_name%> = <%=file_name.capitalize%>.find(params[:id]) | ||
@<%=plural_name%>.destroy | ||
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,32 @@ | ||
class <%=plural_name.capitalize%>Controller < ApplicationController | ||
|
||
def index | ||
@proposals = Proposal.all | ||
end | ||
|
||
def show | ||
@proposal = Proposal.find(params[:id]) | ||
end | ||
|
||
def new | ||
@proposal = Proposal.new | ||
end | ||
|
||
def edit | ||
@proposal = Proposal.find(params[:id]) | ||
end | ||
|
||
def create | ||
@proposal = Proposal.new(params[:proposal]) | ||
end | ||
|
||
def update | ||
@proposal = Proposal.find(params[:id]) | ||
end | ||
|
||
def destroy | ||
@proposal = Proposal.find(params[:id]) | ||
@proposal.destroy | ||
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,6 @@ | ||
<h1>Editing proposal</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @proposal %> | | ||
<%= link_to 'Back', proposals_path %> |
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,7 @@ | ||
!= "$('ul.tabbernav').html('#{j render "shared/tabs"}').show();" | ||
- unless params[:page] | ||
!= "$('#loop_main').html('#{j render(@<%=plural_name%>)}').append('#{j paginate(@<%=plural_name%>)}');" | ||
- else | ||
!= "$('#loop_main').append('#{j render(@<%=plural_name%>)}').append('#{j paginate(@<%=plural_name%>)}');" | ||
!= if "$(#span.next).length" | ||
!= "$('.pagination').remove();" |
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,5 @@ | ||
<h1>New proposal</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', proposals_path %> |
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,5 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
|
||
<%= link_to 'Edit', edit_proposal_path(@proposal) %> | | ||
<%= link_to 'Back', proposals_path %> |