usda linking
This commit is contained in:
parent
2dca779294
commit
ff231ceee0
@ -1,6 +1,6 @@
|
|||||||
class IngredientsController < ApplicationController
|
class IngredientsController < ApplicationController
|
||||||
|
|
||||||
before_action :set_ingredient, only: [:edit, :update, :destroy, :select_ndbn]
|
before_action :set_ingredient, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
before_filter :ensure_valid_user, only: [:new, :edit, :create, :update, :destroy]
|
before_filter :ensure_valid_user, only: [:new, :edit, :create, :update, :destroy]
|
||||||
|
|
||||||
@ -64,7 +64,14 @@ class IngredientsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def select_ndbn
|
def select_ndbn
|
||||||
|
if params[:id].present?
|
||||||
|
@ingredient = Ingredient.find(params[:id])
|
||||||
|
else
|
||||||
|
@ingredient = Ingredient.new
|
||||||
|
end
|
||||||
|
|
||||||
@ingredient.assign_attributes(ingredient_params)
|
@ingredient.assign_attributes(ingredient_params)
|
||||||
|
|
||||||
if @ingredient.ndbn.present?
|
if @ingredient.ndbn.present?
|
||||||
@ingredient.set_usda_food(UsdaFood.find_by_ndbn(@ingredient.ndbn))
|
@ingredient.set_usda_food(UsdaFood.find_by_ndbn(@ingredient.ndbn))
|
||||||
end
|
end
|
||||||
|
@ -16,12 +16,10 @@ Rails.application.routes.draw do
|
|||||||
get :convert
|
get :convert
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
member do
|
|
||||||
match :select_ndbn, via: [:post, :patch, :put]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
match '/ingredients(/:id)/select_ndbn' => 'ingredients#select_ndbn', via: [:post, :patch, :put]
|
||||||
|
|
||||||
resource :user, only: [:new, :create, :edit, :update]
|
resource :user, only: [:new, :create, :edit, :update]
|
||||||
|
|
||||||
get '/login' => 'users#login', as: :login
|
get '/login' => 'users#login', as: :login
|
||||||
|
Loading…
Reference in New Issue
Block a user