Merge branch 'dev' into bw/planting_slug

This commit is contained in:
Shiny
2017-02-12 12:13:37 +13:00
committed by GitHub
3 changed files with 13 additions and 37 deletions

View File

@@ -148,7 +148,6 @@ Style/BarePercentLiterals:
# IgnoredMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'app/controllers/alternate_names_controller.rb'
- 'app/controllers/members_controller.rb'
- 'app/controllers/posts_controller.rb'
- 'app/controllers/scientific_names_controller.rb'
@@ -225,7 +224,6 @@ Style/EmptyMethod:
Exclude:
- 'app/controllers/account_types_controller.rb'
- 'app/controllers/accounts_controller.rb'
- 'app/controllers/alternate_names_controller.rb'
- 'app/controllers/gardens_controller.rb'
- 'app/controllers/photos_controller.rb'
- 'app/controllers/plant_parts_controller.rb'

View File

@@ -1,16 +1,13 @@
class AlternateNamesController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
load_and_authorize_resource
respond_to :html, :json
# GET /alternate_names
# GET /alternate_names.json
def index
@alternate_names = AlternateName.all
respond_to do |format|
format.html # index.html.haml
format.json { render json: @alternate_names }
end
respond_with(@alternate_names)
end
# GET /alternate_names/new
@@ -18,16 +15,10 @@ class AlternateNamesController < ApplicationController
def new
@alternate_name = AlternateName.new
@crop = Crop.find_or_initialize_by(id: params[:crop_id])
respond_to do |format|
format.html # new.html.haml
format.json { render json: @alternate_name }
end
end
# GET /alternate_names/1/edit
def edit
end
def edit; end
# POST /alternate_names
# POST /alternate_names.json
@@ -35,28 +26,20 @@ class AlternateNamesController < ApplicationController
params[:alternate_name][:creator_id] = current_member.id
@alternate_name = AlternateName.new(alternate_name_params)
respond_to do |format|
if @alternate_name.save
format.html { redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.' }
format.json { render json: @alternate_name, status: :created, location: @alternate_name }
else
format.html { render action: "new" }
format.json { render json: @alternate_name.errors, status: :unprocessable_entity }
end
if @alternate_name.save
redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.'
else
render action: "new"
end
end
# PUT /alternate_names/1
# PUT /alternate_names/1.json
def update
respond_to do |format|
if @alternate_name.update(alternate_name_params)
format.html { redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @alternate_name.errors, status: :unprocessable_entity }
end
if @alternate_name.update(alternate_name_params)
redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.'
else
render action: "edit"
end
end
@@ -65,13 +48,7 @@ class AlternateNamesController < ApplicationController
def destroy
@crop = @alternate_name.crop
@alternate_name.destroy
respond_to do |format|
format.html {
redirect_to @crop, notice: 'Alternate name was successfully deleted.'
}
format.json { head :no_content }
end
redirect_to @crop, notice: 'Alternate name was successfully deleted.'
end
private

View File

@@ -4,6 +4,7 @@
%ul#admin_links
%li= link_to "Account types", account_types_path
%li= link_to "Alternate names", alternate_names_path
%li= link_to "Products", products_path
%li= link_to "Roles", roles_path
%li= link_to "Forums", forums_path