-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bin/rails g scaffold stuff title:string expires_at:datetime unlisted:…
…boolean filename:string encrypted_password:string --no-view-specs
- Loading branch information
Showing
15 changed files
with
283 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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,69 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; | ||
} | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; | ||
} | ||
} | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
} |
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,3 @@ | ||
// Place all the styles related to the stuffs controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,74 @@ | ||
class StuffsController < ApplicationController | ||
before_action :set_stuff, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /stuffs | ||
# GET /stuffs.json | ||
def index | ||
@stuffs = Stuff.all | ||
end | ||
|
||
# GET /stuffs/1 | ||
# GET /stuffs/1.json | ||
def show | ||
end | ||
|
||
# GET /stuffs/new | ||
def new | ||
@stuff = Stuff.new | ||
end | ||
|
||
# GET /stuffs/1/edit | ||
def edit | ||
end | ||
|
||
# POST /stuffs | ||
# POST /stuffs.json | ||
def create | ||
@stuff = Stuff.new(stuff_params) | ||
|
||
respond_to do |format| | ||
if @stuff.save | ||
format.html { redirect_to @stuff, notice: 'Stuff was successfully created.' } | ||
format.json { render :show, status: :created, location: @stuff } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @stuff.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /stuffs/1 | ||
# PATCH/PUT /stuffs/1.json | ||
def update | ||
respond_to do |format| | ||
if @stuff.update(stuff_params) | ||
format.html { redirect_to @stuff, notice: 'Stuff was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @stuff } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @stuff.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /stuffs/1 | ||
# DELETE /stuffs/1.json | ||
def destroy | ||
@stuff.destroy | ||
respond_to do |format| | ||
format.html { redirect_to stuffs_url, notice: 'Stuff was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_stuff | ||
@stuff = Stuff.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def stuff_params | ||
params.require(:stuff).permit(:title, :expires_at, :unlisted, :filename, :encrypted_password) | ||
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,2 @@ | ||
module StuffsHelper | ||
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,2 @@ | ||
class Stuff < ActiveRecord::Base | ||
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,37 @@ | ||
<%= form_for(@stuff) do |f| %> | ||
<% if @stuff.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@stuff.errors.count, "error") %> prohibited this stuff from being saved:</h2> | ||
|
||
<ul> | ||
<% @stuff.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :title %><br> | ||
<%= f.text_field :title %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :expires_at %><br> | ||
<%= f.datetime_select :expires_at %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :unlisted %><br> | ||
<%= f.check_box :unlisted %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :filename %><br> | ||
<%= f.text_field :filename %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :encrypted_password %><br> | ||
<%= f.text_field :encrypted_password %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% 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 stuff</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @stuff %> | | ||
<%= link_to 'Back', stuffs_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,33 @@ | ||
<h1>Listing stuffs</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Expires at</th> | ||
<th>Unlisted</th> | ||
<th>Filename</th> | ||
<th>Encrypted password</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @stuffs.each do |stuff| %> | ||
<tr> | ||
<td><%= stuff.title %></td> | ||
<td><%= stuff.expires_at %></td> | ||
<td><%= stuff.unlisted %></td> | ||
<td><%= stuff.filename %></td> | ||
<td><%= stuff.encrypted_password %></td> | ||
<td><%= link_to 'Show', stuff %></td> | ||
<td><%= link_to 'Edit', edit_stuff_path(stuff) %></td> | ||
<td><%= link_to 'Destroy', stuff, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Stuff', new_stuff_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,4 @@ | ||
json.array!(@stuffs) do |stuff| | ||
json.extract! stuff, :id, :title, :expires_at, :unlisted, :filename, :encrypted_password | ||
json.url stuff_url(stuff, format: :json) | ||
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,5 @@ | ||
<h1>New stuff</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', stuffs_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,29 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Title:</strong> | ||
<%= @stuff.title %> | ||
</p> | ||
|
||
<p> | ||
<strong>Expires at:</strong> | ||
<%= @stuff.expires_at %> | ||
</p> | ||
|
||
<p> | ||
<strong>Unlisted:</strong> | ||
<%= @stuff.unlisted %> | ||
</p> | ||
|
||
<p> | ||
<strong>Filename:</strong> | ||
<%= @stuff.filename %> | ||
</p> | ||
|
||
<p> | ||
<strong>Encrypted password:</strong> | ||
<%= @stuff.encrypted_password %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_stuff_path(@stuff) %> | | ||
<%= link_to 'Back', stuffs_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 @@ | ||
json.extract! @stuff, :id, :title, :expires_at, :unlisted, :filename, :encrypted_password, :created_at, :updated_at |
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,13 @@ | ||
class CreateStuffs < ActiveRecord::Migration | ||
def change | ||
create_table :stuffs do |t| | ||
t.string :title | ||
t.datetime :expires_at | ||
t.boolean :unlisted | ||
t.string :filename | ||
t.string :encrypted_password | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |