Skip to content

Instantly share code, notes, and snippets.

@aakashd
Last active July 20, 2016 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aakashd/5531908 to your computer and use it in GitHub Desktop.
Save aakashd/5531908 to your computer and use it in GitHub Desktop.
ActiveAdmin.register NutritionData do
menu false
form do |f|
f.inputs "Details" do
f.input :item_id, :as => :hidden
f.input :header, :input_html => {:rows => 5}
f.input :serving, :input_html => {:rows => 5}
f.input :calories
f.input :calories_from_fat
end
f.has_many :nutrition_items do |nutrition_item|
if nutrition_item.object.new_record?
nutrition_item.input :title
nutrition_item.input :value
else
nutrition_item.input :title
nutrition_item.input :value
nutrition_item.input :_destroy, :as => :boolean, :required => false, :label => 'Remove Nutrition Item'
end
nutrition_item.has_many :child_nutrition_items do |child_nutrition_item|
if child_nutrition_item.object.new_record?
child_nutrition_item.input :title
child_nutrition_item.input :value
else
child_nutrition_item.input :title
child_nutrition_item.input :value
child_nutrition_item.input :_destroy, :as => :boolean, :required => false, :label => 'Remove Nutrition Child Item'
end
end
end
f.buttons
end
controller do
def create_with_redirect_to_item
create_without_redirect_to_item do |success, failure|
if success.nil? != nil
redirect_to admin_item_url(@nutrition_data.item)
return
end
end
end
alias_method_chain :create, :redirect_to_item
def update_with_redirect_to_item
update_without_redirect_to_item do |success, failure|
if success.nil? != nil
redirect_to admin_item_url(@nutrition_data.item)
return
end
end
end
alias_method_chain :update, :redirect_to_item
def destroy_with_redirect_to_item
destroy_without_redirect_to_item do |success, failure|
if success
redirect_to admin_item_url(@nutrition_data.item)
return
end
end
end
alias_method_chain :destroy, :redirect_to_item
end
end
GIT
remote: git://github.com/gregbell/active_admin.git
revision: 18438fcc82ef12f74d43f65766125eac466f79fc
ref: 18438fcc82ef12f74d43f65766125eac466f79fc
specs:
activeadmin (0.5.0)
arbre (>= 1.0.1)
bourbon (>= 1.0.0)
devise (>= 1.1.2)
fastercsv
formtastic (>= 2.0.0)
inherited_resources (>= 1.3.1)
jquery-rails (>= 1.0.0)
kaminari (>= 0.13.0)
meta_search (>= 0.9.2)
rails (>= 3.0.0)
sass (>= 3.1.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.8)
arbre (1.0.1)
activesupport (>= 3.0.0)
arel (3.0.2)
aws-sdk (1.8.0)
httparty (~> 0.7)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt-ruby (3.0.1)
better_errors (0.3.2)
coderay (>= 1.0.0)
erubis (>= 2.7.0)
binding_of_caller (0.6.8)
bourbon (3.1.6)
sass (>= 3.2.0)
thor
bourne (1.1.2)
mocha (= 0.10.5)
builder (3.0.4)
cancan (1.6.8)
capybara (2.0.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
capybara-webkit (0.14.2)
capybara (~> 2.0, >= 2.0.2)
json
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
chunky_png (1.2.7)
cocaine (0.4.2)
coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.4.0)
commands (0.2.1)
rails (>= 3.2.0)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
compass-normalize (1.4.2)
compass (>= 0.12.0)
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
compass-rgbapng (0.1.1)
chunky_png (>= 0.8.0)
compass (>= 0.10.0)
css_parser (1.3.4)
addressable
cucumber (1.2.3)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.6)
multi_json (~> 1.3)
cucumber-rails (1.3.0)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
daemons (1.1.9)
database_cleaner (0.9.1)
delayed_job (3.0.4)
activesupport (~> 3.0)
delayed_job_active_record (0.3.3)
activerecord (>= 2.1.0, < 4)
delayed_job (~> 3.0)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
draper (0.18.0)
actionpack (~> 3.2)
activesupport (~> 3.2)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.1.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.1.0)
factory_girl (~> 4.1.0)
railties (>= 3.0.0)
faraday (0.8.4)
multipart-post (~> 1.1)
fastercsv (1.5.5)
ffi (1.4.0)
formtastic (2.2.1)
actionpack (>= 3.0)
friendly_id (4.0.9)
fssm (0.2.9)
gherkin (2.11.6)
json (>= 1.7.6)
googlecharts (1.6.8)
has_scope (0.5.1)
hashie (1.2.0)
hike (1.2.2)
httparty (0.9.0)
multi_json (~> 1.0)
multi_xml
httpauth (0.2.0)
i18n (0.6.4)
inherited_resources (1.4.0)
has_scope (~> 0.5.0)
responders (~> 0.9)
journey (1.0.4)
jquery-rails (2.1.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
js-routes (0.8.5)
rails (>= 3.2)
json (1.7.7)
jwt (0.1.5)
multi_json (>= 1.0)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
launchy (2.1.0)
addressable (~> 2.2.6)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_search (1.1.3)
actionpack (~> 3.1)
activerecord (~> 3.1)
activesupport (~> 3.1)
polyamorous (~> 0.5.0)
metaclass (0.0.1)
mime-types (1.23)
mocha (0.10.5)
metaclass (~> 0.0.1)
money (5.1.0)
i18n (~> 0.6.0)
money-rails (0.7.1)
activesupport (~> 3.0)
money (~> 5.1.0)
railties (~> 3.0)
multi_json (1.7.3)
multi_xml (0.5.1)
multipart-post (1.1.5)
nokogiri (1.5.6)
oauth (0.4.7)
oauth2 (0.8.0)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
omniauth (1.1.1)
hashie (~> 1.2)
rack
omniauth-facebook (1.4.1)
omniauth-oauth2 (~> 1.1.0)
omniauth-oauth (1.0.1)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.1.1)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-twitter (0.0.14)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
orm_adapter (0.4.0)
paperclip (3.4.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.4.0)
mime-types
pg (0.14.1)
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.3)
pr_geohash (1.0.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
responders (0.9.3)
railties (~> 3.1)
roadie (2.3.4)
actionmailer (> 3.0.0, < 3.3.0)
css_parser
nokogiri (>= 1.4.4)
sprockets
rsolr (1.0.8)
builder (>= 2.1.2)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-http (0.10.0)
rspec (~> 2.0)
rspec-mocks (2.12.1)
rspec-rails (2.12.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
ruby-ole (1.2.11.6)
rubyzip (0.9.9)
sass (3.2.8)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.31.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
settingslogic (2.0.9)
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)
bourne (~> 1.1.2)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
spork (1.0.0rc3)
spork-rails (3.2.0)
rails (>= 3.0.0, < 3.3.0)
spork (>= 1.0rc0)
spreadsheet (0.7.6)
ruby-ole (>= 1.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sunspot (1.3.3)
pr_geohash (~> 1.0)
rsolr (~> 1.0.7)
sunspot_rails (1.3.3)
nokogiri
sunspot (= 1.3.3)
sunspot_solr (1.3.3)
sunspot_test (0.4.0)
sunspot_rails (>= 1.2.1)
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.18.1)
tilt (1.4.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uuidtools (2.1.3)
warden (1.2.1)
rack (>= 1.0)
websocket (1.0.7)
xpath (1.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
activeadmin!
aws-sdk
better_errors
binding_of_caller
cancan
capybara-webkit
coffee-rails
commands
compass-normalize
compass-rails
compass-rgbapng
cucumber-rails
database_cleaner
delayed_job_active_record
draper
factory_girl_rails
friendly_id
googlecharts
hashie
jquery-rails (= 2.1.3)
js-routes
launchy
money-rails
omniauth
omniauth-facebook
omniauth-twitter
paperclip
pg
rails (= 3.2.8)
roadie
rspec
rspec-http
rspec-rails
sass-rails
settingslogic
shoulda-matchers
simplecov
spork-rails
spreadsheet
sunspot_rails
sunspot_solr
sunspot_test
thin
uglifier (>= 1.0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment