diff --git a/app/controllers/configurations_controller.rb b/app/controllers/configurations_controller.rb new file mode 100644 index 0000000..9f91465 --- /dev/null +++ b/app/controllers/configurations_controller.rb @@ -0,0 +1,29 @@ +class ConfigurationsController < ApplicationController + + def show + @configuration = Configuration.find(params[:id]) + end + + def new + @configuration = Configuration.new + end + + def create + @configuration = Configuration.new(configuration_params) + if @configuration.save + redirect_to @configuration, + notice: 'Configuração criada com sucesso!' + else + render action: :new + end + end + + private + + def configuration_params + params. + require(:configuration). + permit(:name, :description) + end + +end diff --git a/app/views/configurations/_form.html.erb b/app/views/configurations/_form.html.erb new file mode 100644 index 0000000..96c6257 --- /dev/null +++ b/app/views/configurations/_form.html.erb @@ -0,0 +1,16 @@ +<%= form_for(@configuration, :html => { role: 'form' }) do |f| %> + <%= render :partial => 'shared/form_errors', :locals => {:object => @configuration} %> + +
+ <%= f.label :name, class: 'control-label' %>
+ <%= f.text_field :name, class: 'form-control' %> +
+ +
+ <%= f.label :description, class: 'control-label' %>
+ <%= f.text_area :description, class: 'form-control' %> +
+ + <%= f.submit 'Save', class: 'btn btn-primary' %> + +<% end %> diff --git a/app/views/configurations/edit.html.erb b/app/views/configurations/edit.html.erb new file mode 100644 index 0000000..352fbab --- /dev/null +++ b/app/views/configurations/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Configuration

+ +<%= render 'form' %> diff --git a/app/views/configurations/new.html.erb b/app/views/configurations/new.html.erb new file mode 100644 index 0000000..7af2737 --- /dev/null +++ b/app/views/configurations/new.html.erb @@ -0,0 +1,3 @@ +

New Configuration

+ +<%= render 'form' %> diff --git a/app/views/configurations/show.html.erb b/app/views/configurations/show.html.erb new file mode 100644 index 0000000..6e016f4 --- /dev/null +++ b/app/views/configurations/show.html.erb @@ -0,0 +1,7 @@ +

Configuração: <%= @configuration.name %>

+ + + +<%= link_to 'Editar', edit_configuration_path(@configuration) %> \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 366aa60..2769947 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -27,12 +27,6 @@ ActiveRecord::Schema.define(version: 20131219115819) do t.datetime "updated_at" end - create_table "repositories", force: true do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "users", force: true do |t| t.string "name", default: "", null: false t.string "email", default: "", null: false -- libgit2 0.21.2