diff --git a/app/controllers/admin/faqs_controller.rb b/app/controllers/admin/faqs_controller.rb index 9854b72..017dc14 100644 --- a/app/controllers/admin/faqs_controller.rb +++ b/app/controllers/admin/faqs_controller.rb @@ -1,63 +1,63 @@ class Admin::FaqsController < Admin::BaseController before_action :fetch_faq, only: [:show, :edit, :update, :destroy] # GET /admin/faqs def index @faqs = Faq.all end # GET /admin/faqs/:id def show; end # GET /admin/faqs/new def new @faq = Faq.new end # GET /admin/faqs/:id/edit def edit; end # POST /admin/faqs def create @faq = Faq.new(fetch_params) if @faq.save flash[:success] = 'FAQ created successfuly' redirect_to admin_faqs_path else flash[:error] = 'FAQ not created' render :new end end # PUT/PATCH /admin/faqs/:id/update def update if @faq.update_attributes(fetch_params) flash[:success] = 'FAQ updated successfuly' redirect_to admin_faq_path(@faq) else flash[:error] = 'FAQ not updated' render :edit end end # DELETE /admin/faqs/:id/destroy def destroy if @faq.destroy flash[:success] = 'FAQ destroyed' else flash[:error] = 'FAQ not destroyed' end redirect_to admin_faqs_path end private def fetch_faq @faq = Faq.find(params[:id]) end def fetch_params - params.require(:faq).permit(:title, :body) + params.require(:faq).permit(:title, :body, :priority) end end diff --git a/app/views/admin/faqs/_form.html.erb b/app/views/admin/faqs/_form.html.erb index cb78c2c..6dfddd3 100644 --- a/app/views/admin/faqs/_form.html.erb +++ b/app/views/admin/faqs/_form.html.erb @@ -1,16 +1,16 @@ <%= bootstrap_form_for([:admin, @faq], layout: :horizontal, label_col: 'col-xs-3', control_col: 'col-xs-8') do |f| %> <%= f.text_field :title, required: true %> <%= f.number_field :priority %> <%= f.text_area :body, cols: 20, rows: 10, required: true %>
<%= link_to 'Cancel', admin_faqs_path, class: 'btn btn-default' %>
-
+
<%= f.submit class: 'btn btn-success' %>
<% end %> diff --git a/app/views/admin/faqs/edit.html.erb b/app/views/admin/faqs/edit.html.erb index 84fc9b0..105e698 100644 --- a/app/views/admin/faqs/edit.html.erb +++ b/app/views/admin/faqs/edit.html.erb @@ -1,11 +1,12 @@
-
+

Edit FAQ

-
- <%= render partial: 'form' %> +
+ <%= render partial: 'form' %> +
diff --git a/app/views/admin/faqs/new.html.erb b/app/views/admin/faqs/new.html.erb index 50735e2..31c03e0 100644 --- a/app/views/admin/faqs/new.html.erb +++ b/app/views/admin/faqs/new.html.erb @@ -1,11 +1,12 @@
-
+

New FAQ entry

-
- <%= render partial: 'form' %> +
+ <%= render partial: 'form' %> +
diff --git a/app/views/admin/faqs/show.html.erb b/app/views/admin/faqs/show.html.erb index e237ea0..df0b686 100644 --- a/app/views/admin/faqs/show.html.erb +++ b/app/views/admin/faqs/show.html.erb @@ -1,26 +1,22 @@

<%= @faq.title %>

-
- -

+

<%= @faq.pretty_body %> -

+
- <%= link_to 'Back to FAQ', admin_faqs_path %> - <%= link_to edit_admin_faq_path(@faq), class: 'btn btn-default' do %> Edit <% end %> <%= link_to admin_faq_path(@faq), method: :delete, data: { confirm: 'FAQ entry will be deleted' }, class: 'btn btn-default right' do %> Delete <% end %>