Commit 7ba5c4a4bed46ec4fa11176fcdbdca5699296a47

Authored by vinicim
Committed by Rafael Manzo
1 parent 0a8d1cf0

controller and views added to configuration model

app/controllers/configurations_controller.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +class ConfigurationsController < ApplicationController
  2 +
  3 + def show
  4 + @configuration = Configuration.find(params[:id])
  5 + end
  6 +
  7 + def new
  8 + @configuration = Configuration.new
  9 + end
  10 +
  11 + def create
  12 + @configuration = Configuration.new(configuration_params)
  13 + if @configuration.save
  14 + redirect_to @configuration,
  15 + notice: 'Configuração criada com sucesso!'
  16 + else
  17 + render action: :new
  18 + end
  19 + end
  20 +
  21 + private
  22 +
  23 + def configuration_params
  24 + params.
  25 + require(:configuration).
  26 + permit(:name, :description)
  27 + end
  28 +
  29 +end
... ...
app/views/configurations/_form.html.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<%= form_for(@configuration, :html => { role: 'form' }) do |f| %>
  2 + <%= render :partial => 'shared/form_errors', :locals => {:object => @configuration} %>
  3 +
  4 + <div class="form-group">
  5 + <%= f.label :name, class: 'control-label' %><br>
  6 + <%= f.text_field :name, class: 'form-control' %>
  7 + </div>
  8 +
  9 + <div class="form-group">
  10 + <%= f.label :description, class: 'control-label' %><br>
  11 + <%= f.text_area :description, class: 'form-control' %>
  12 + </div>
  13 +
  14 + <%= f.submit 'Save', class: 'btn btn-primary' %>
  15 +
  16 +<% end %>
... ...
app/views/configurations/edit.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<h1>Edit Configuration</h1>
  2 +
  3 +<%= render 'form' %>
... ...
app/views/configurations/new.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<h1>New Configuration</h1>
  2 +
  3 +<%= render 'form' %>
... ...
app/views/configurations/show.html.erb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<h2>Configuração: <%= @configuration.name %> </h2>
  2 +
  3 +<ul>
  4 + <li>Descrição: <%= @configuration.description %> </li>
  5 +</ul>
  6 +
  7 +<%= link_to 'Editar', edit_configuration_path(@configuration) %>
0 8 \ No newline at end of file
... ...
db/schema.rb
... ... @@ -27,12 +27,6 @@ ActiveRecord::Schema.define(version: 20131219115819) do
27 27 t.datetime "updated_at"
28 28 end
29 29  
30   - create_table "repositories", force: true do |t|
31   - t.string "name"
32   - t.datetime "created_at"
33   - t.datetime "updated_at"
34   - end
35   -
36 30 create_table "users", force: true do |t|
37 31 t.string "name", default: "", null: false
38 32 t.string "email", default: "", null: false
... ...