Commit 7ba5c4a4bed46ec4fa11176fcdbdca5699296a47
Committed by
Rafael Manzo
1 parent
0a8d1cf0
Exists in
colab
and in
4 other branches
controller and views added to configuration model
Showing
6 changed files
with
58 additions
and
6 deletions
Show diff stats
| ... | ... | @@ -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 | ... | ... |
| ... | ... | @@ -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 %> | ... | ... |
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 | ... | ... |