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
3c719bd
commit fac5033
Showing
18 changed files
with
374 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://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 Cursos 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 CursosController < ApplicationController | ||
# GET /cursos | ||
# GET /cursos.json | ||
def index | ||
@cursos = Curso.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @cursos } | ||
end | ||
end | ||
|
||
# GET /cursos/1 | ||
# GET /cursos/1.json | ||
def show | ||
@curso = Curso.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @curso } | ||
end | ||
end | ||
|
||
# GET /cursos/new | ||
# GET /cursos/new.json | ||
def new | ||
@curso = Curso.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @curso } | ||
end | ||
end | ||
|
||
# GET /cursos/1/edit | ||
def edit | ||
@curso = Curso.find(params[:id]) | ||
end | ||
|
||
# POST /cursos | ||
# POST /cursos.json | ||
def create | ||
@curso = Curso.new(params[:curso]) | ||
|
||
respond_to do |format| | ||
if @curso.save | ||
format.html { redirect_to @curso, notice: 'Curso was successfully created.' } | ||
format.json { render json: @curso, status: :created, location: @curso } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @curso.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /cursos/1 | ||
# PUT /cursos/1.json | ||
def update | ||
@curso = Curso.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @curso.update_attributes(params[:curso]) | ||
format.html { redirect_to @curso, notice: 'Curso was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @curso.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /cursos/1 | ||
# DELETE /cursos/1.json | ||
def destroy | ||
@curso = Curso.find(params[:id]) | ||
@curso.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to cursos_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CursosHelper | ||
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 Curso < 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(@curso) do |f| %> | ||
<% if @curso.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@curso.errors.count, "error") %> prohibited this curso from being saved:</h2> | ||
|
||
<ul> | ||
<% @curso.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :nombre %><br /> | ||
<%= f.text_field :nombre %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :formula %><br /> | ||
<%= f.text_field :formula %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :cantpcs %><br /> | ||
<%= f.number_field :cantpcs %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :exafinal %><br /> | ||
<%= f.check_box :exafinal %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :proyecto %><br /> | ||
<%= f.check_box :proyecto %> | ||
</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 curso</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @curso %> | | ||
<%= link_to 'Back', cursos_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,31 @@ | ||
<h1>Listing cursos</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Nombre</th> | ||
<th>Formula</th> | ||
<th>Cantpcs</th> | ||
<th>Exafinal</th> | ||
<th>Proyecto</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @cursos.each do |curso| %> | ||
<tr> | ||
<td><%= curso.nombre %></td> | ||
<td><%= curso.formula %></td> | ||
<td><%= curso.cantpcs %></td> | ||
<td><%= curso.exafinal %></td> | ||
<td><%= curso.proyecto %></td> | ||
<td><%= link_to 'Show', curso %></td> | ||
<td><%= link_to 'Edit', edit_curso_path(curso) %></td> | ||
<td><%= link_to 'Destroy', curso, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Curso', new_curso_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 @@ | ||
<h1>New curso</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', cursos_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,30 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Nombre:</b> | ||
<%= @curso.nombre %> | ||
</p> | ||
|
||
<p> | ||
<b>Formula:</b> | ||
<%= @curso.formula %> | ||
</p> | ||
|
||
<p> | ||
<b>Cantpcs:</b> | ||
<%= @curso.cantpcs %> | ||
</p> | ||
|
||
<p> | ||
<b>Exafinal:</b> | ||
<%= @curso.exafinal %> | ||
</p> | ||
|
||
<p> | ||
<b>Proyecto:</b> | ||
<%= @curso.proyecto %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_curso_path(@curso) %> | | ||
<%= link_to 'Back', cursos_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
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 CreateCursos < ActiveRecord::Migration | ||
def change | ||
create_table :cursos do |t| | ||
t.string :nombre | ||
t.string :formula | ||
t.integer :cantpcs | ||
t.boolean :exafinal | ||
t.boolean :proyecto | ||
|
||
t.timestamps | ||
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,26 @@ | ||
# encoding: UTF-8 | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended to check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(:version => 20120317220952) do | ||
|
||
create_table "cursos", :force => true do |t| | ||
t.string "nombre" | ||
t.string "formula" | ||
t.integer "cantpcs" | ||
t.boolean "exafinal" | ||
t.boolean "proyecto" | ||
t.datetime "created_at", :null => false | ||
t.datetime "updated_at", :null => false | ||
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,15 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html | ||
|
||
one: | ||
nombre: MyString | ||
formula: MyString | ||
cantpcs: 1 | ||
exafinal: false | ||
proyecto: false | ||
|
||
two: | ||
nombre: MyString | ||
formula: MyString | ||
cantpcs: 1 | ||
exafinal: false | ||
proyecto: false |
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,49 @@ | ||
require 'test_helper' | ||
|
||
class CursosControllerTest < ActionController::TestCase | ||
setup do | ||
@curso = cursos(:one) | ||
end | ||
|
||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:cursos) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create curso" do | ||
assert_difference('Curso.count') do | ||
post :create, curso: @curso.attributes | ||
end | ||
|
||
assert_redirected_to curso_path(assigns(:curso)) | ||
end | ||
|
||
test "should show curso" do | ||
get :show, id: @curso | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, id: @curso | ||
assert_response :success | ||
end | ||
|
||
test "should update curso" do | ||
put :update, id: @curso, curso: @curso.attributes | ||
assert_redirected_to curso_path(assigns(:curso)) | ||
end | ||
|
||
test "should destroy curso" do | ||
assert_difference('Curso.count', -1) do | ||
delete :destroy, id: @curso | ||
end | ||
|
||
assert_redirected_to cursos_path | ||
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 @@ | ||
require 'test_helper' | ||
|
||
class CursoTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert 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,4 @@ | ||
require 'test_helper' | ||
|
||
class CursosHelperTest < ActionView::TestCase | ||
end |