Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Associating printer model with totem model
- Loading branch information
1 parent
7b54a11
commit d2e722c
Showing
27 changed files
with
537 additions
and
5 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://jashkenas.github.com/coffee-script/ |
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 printers 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,56 @@ | ||
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,83 @@ | ||
class PrintersController < ApplicationController | ||
# GET /printers | ||
# GET /printers.json | ||
def index | ||
@printers = Printer.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @printers } | ||
end | ||
end | ||
|
||
# GET /printers/1 | ||
# GET /printers/1.json | ||
def show | ||
@printer = Printer.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @printer } | ||
end | ||
end | ||
|
||
# GET /printers/new | ||
# GET /printers/new.json | ||
def new | ||
@printer = Printer.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @printer } | ||
end | ||
end | ||
|
||
# GET /printers/1/edit | ||
def edit | ||
@printer = Printer.find(params[:id]) | ||
end | ||
|
||
# POST /printers | ||
# POST /printers.json | ||
def create | ||
@printer = Printer.new(params[:printer]) | ||
|
||
respond_to do |format| | ||
if @printer.save | ||
format.html { redirect_to @printer, notice: 'Printer was successfully created.' } | ||
format.json { render json: @printer, status: :created, location: @printer } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @printer.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /printers/1 | ||
# PUT /printers/1.json | ||
def update | ||
@printer = Printer.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @printer.update_attributes(params[:printer]) | ||
format.html { redirect_to @printer, notice: 'Printer was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @printer.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /printers/1 | ||
# DELETE /printers/1.json | ||
def destroy | ||
@printer = Printer.find(params[:id]) | ||
@printer.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to printers_url } | ||
format.json { head :no_content } | ||
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
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 PrintersHelper | ||
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,11 @@ | ||
class Printer < ActiveRecord::Base | ||
extend FriendlyId | ||
|
||
friendly_id :name, use: :slugged | ||
|
||
attr_accessible :name | ||
|
||
has_many :totems | ||
|
||
validates :name, :presence => true | ||
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
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,22 @@ | ||
<%= form_for(@printer) do |f| %> | ||
<% if @printer.errors.any? %> | ||
<div id="error_explanation"> | ||
<ul> | ||
<% @printer.errors.full_messages.each do |msg| %> | ||
<li class="form-msg-error"><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="grid-12-12"> | ||
<%= f.label :name, :class => "form-lbl form-req" %> | ||
<%= f.text_field :name, :maxlength => 80, :size => 30, :class => "form-txt form-small", :disabled => disabled %> | ||
</div> | ||
|
||
<% unless disabled %> | ||
<div class="grid-7-12 field-button field-clear"> | ||
<%= f.submit :class => "button form-right medium" %> | ||
</div> | ||
<% 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 @@ | ||
<div class="form"> | ||
<fieldset> | ||
<legend><%= t('model.print.editing') %></legend> | ||
<%= render :partial => 'form', :locals => {:disabled => false } %> | ||
</fieldset> | ||
</div> | ||
<div class="buttons-nav"> | ||
<%= link_to t('model.show'), printer_path(@printer), :class => "button medium" %> | ||
<%= link_to t('model.back'), printers_path, :class => "button medium" %> | ||
</div> |
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,24 @@ | ||
<div class="form"> | ||
<div class="search"> | ||
<input type="text" value="search" id="search"/> | ||
<%= link_to image_tag("form/search.png") + t('application.search') , "#", :class => "button medium"%> | ||
</div> | ||
<table> | ||
<tr> | ||
<th><%= t('model.printer.name').pluralize %></th> | ||
<th colspan="3" class="options"><%= t("application.options") %></th> | ||
</tr> | ||
<% @printers.each do |printer| %> | ||
<tr class="row"> | ||
<td width ="100%"><%= printer.name %></td> | ||
<td><%= link_to image_tag("form/search.gif"), printer %></td> | ||
<td><%= link_to image_tag("form/edit.gif"), edit_printer_path(printer) %></td> | ||
<td><%= link_to image_tag("form/trash.gif"), "#" %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
</div> | ||
|
||
<div class="buttons-nav"> | ||
<%= link_to t('model.printer.new'), new_printer_path , :class => "button medium"%> | ||
</div> |
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,9 @@ | ||
<div class="form"> | ||
<fieldset> | ||
<legend><%= t('model.printer.new') %></legend> | ||
<%= render :partial => 'form', :locals => { :disabled => false } %> | ||
</fieldset> | ||
</div> | ||
<div class="buttons-nav"> | ||
<%= link_to t('model.back'), printers_path , :class => "button medium"%> | ||
</div> |
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,14 @@ | ||
<div class="form"> | ||
<fieldset> | ||
<legend><%= t('model.printer.name') %></legend> | ||
<% if notice %> | ||
<span class="form-msg-success"><%= notice %></span> | ||
<% end %> | ||
<%= render :partial => 'form', :locals => { :disabled => true } %> | ||
</fieldset> | ||
</div> | ||
|
||
<div class="buttons-nav"> | ||
<%= link_to t('model.edit'), edit_printer_path(@printer), :class => "button medium" %> | ||
<%= link_to t('model.back'), printers_path, :class => "button medium" %> | ||
</div> |
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
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
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,12 @@ | ||
class CreatePrinters < ActiveRecord::Migration | ||
def change | ||
create_table :printers do |t| | ||
t.string :name, :null => false | ||
t.string :slug | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :printers, :slug, unique: true | ||
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,7 @@ | ||
class AddPrinterToTotem < ActiveRecord::Migration | ||
def change | ||
add_column :totems, :printer_id, :integer | ||
|
||
add_index :totems, :printer_id | ||
end | ||
end |
Oops, something went wrong.