Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model caching in development mode #835

Closed
amalagaura opened this issue Dec 9, 2011 · 23 comments
Closed

model caching in development mode #835

amalagaura opened this issue Dec 9, 2011 · 23 comments

Comments

@amalagaura
Copy link
Contributor

I am using edge activeadmin

I have config.cache_classes = false and no problems in regular application, but in ActiveAdmin my models are caching, specifically when I change instance methods, they do not get updated on a page refresh (works in other parts of the app)

@rafalklo
Copy link

I have the same problem, is there a way of configuring ActiveAdmin to remove Model caching ?

@antstorm
Copy link

Same problem here. Using activeadmin (0.3.1)

@sebfie
Copy link

sebfie commented Jan 5, 2012

Any solution for that?

@rainchen
Copy link

same issue , app/models are not being reloaded

osx 10.6.8
activeadmin (0.3.4)
rails (3.1.3)
ruby-1.9.2-p180

@rainchen
Copy link

inspired by #707, add below to /config/initializers/active_admin.rb for a quick fix:

if Rails.env == "development"
  activeadmin_reloader = ActiveSupport::FileUpdateChecker.new(Dir["app/models/**/*"], true) do
    ActiveAdmin.application.unload!
    Rails.application.reload_routes!
  end

  ActionDispatch::Callbacks.to_prepare do
    activeadmin_reloader.execute_if_updated
  end
end

@svoop
Copy link

svoop commented Jan 23, 2012

The above workaround does not work on rails-3.2 and activeadmin-fb515af

@sebfie
Copy link

sebfie commented Jan 23, 2012

So, do you have an other solution?

Thanks

@svoop
Copy link

svoop commented Jan 23, 2012

I'm close to a deadline, so I can't investigate this further at the moment. It's bitter, but restarting the server does the trick of course.

@sebfie
Copy link

sebfie commented Jan 27, 2012

Ok, i understand :) Good luck !

@houen
Copy link

houen commented Feb 22, 2012

Same problem here on Rails 3.1

@Rio517
Copy link

Rio517 commented Feb 29, 2012

Same here!

@Rio517
Copy link

Rio517 commented Feb 29, 2012

This solution worked for me: #931 (comment)

@laurajcordoba
Copy link

Thanks Rainchen this works for me!
On Ubuntu, with ActiveAdmin 0.3.4 and Rails 3.1.1

@pcreux
Copy link
Contributor

pcreux commented Mar 28, 2012

Fixed by #931

@pcreux pcreux closed this as completed Mar 28, 2012
@datnt
Copy link

datnt commented Dec 25, 2012

This issue still there, mac os x 10.6.6i, rails 3.2, activeadmin latest version installed from gihub

@chrisnicola
Copy link

Having this myself, have to restart rails to get any changes to take effect for active admin namespaced controllers.

@seanlinsley
Copy link
Contributor

@LucisFerre this is about model reloading; see #697 for info on the controller side of things.

@themi
Copy link

themi commented Jul 31, 2013

I have the follwing setup

Mac OSX 10.8.4
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
rails (3.2.14)
activeadmin (0.6.0)

admin/members.rb

ActiveAdmin.register Member do
end

config/envronments/develop.rb

config.cache_classes = false

http://localhost:3000/admin/members/303

\o/  views details as expected  

But when I deployed to my unbuntu 12.0.4 server

http://*****/admin/members/303

ActionView::Template::Error (undefined method `block' for #<Hash:0x00000002c5ca40>):
    1: insert_tag renderer_for(:show)
  activeadmin (0.6.0) lib/active_admin/views/pages/show.rb:19:in `main_content'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:78:in `block (2 levels) in build_main_content_wrapper'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:77:in `block in build_main_content_wrapper'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:76:in `build_main_content_wrapper'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:60:in `block in build_page_content'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:59:in `build_page_content'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:42:in `block (2 levels) in build_page'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:39:in `block in build_page'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:38:in `build_page'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:10:in `build'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  activeadmin (0.6.0) app/views/active_admin/resource/show.html.arb:1:in `block in __u_apps_member_payment_staging_shared_bundle_ruby_______gems_activeadmin_______app_views_active_admin_resource_show_html_arb___4192980598549889159_43818160'
  arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
  arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
  activeadmin (0.6.0) app/views/active_admin/resource/show.html.arb:1:in `new'
  activeadmin (0.6.0) app/views/active_admin/resource/show.html.arb:1:in `__u_apps_member_payment_staging_shared_bundle_ruby_______gems_activeadmin_______app_views_active_admin_resource_show_html_arb___4192980598549889159_43818160'

  ...

This happens on all the models setup in admin/folder. Ok, so I found this issue/thread and so... on my pc changed:

config/envronments/develop.rb

config.cache_classes = true

and running this time produced the same error

NoMethodError in Admin/members#show

Showing /Users/themi/.rvm/gems/ruby-1.9.3-p448@member_payment/gems/activeadmin-0.6.0/app/views/active_admin/resource/show.html.arb where line #1 raised:

undefined method `block' for #<Hash:0x007f92a9aea3d8>
Extracted source (around line #1):

1: insert_tag renderer_for(:show)
Rails.root: /Users/themi/projects/jobfutures/member_payment

As I didnt want to change config.cache_classe in my staging (and production) configs I just added a show block for my activeadmin file to make sure there was a block.

admin/members.rb

ActiveAdmin.register Member do
  show do |member|
    attributes_table do
      row :id
      row :name
    end
  end
end

Hope this data sheds more light on the issue. CC @leomao10

@seanlinsley
Copy link
Contributor

@themi can you post a Rails app to GitHub that reproduces this problem?

@themi
Copy link

themi commented Jul 31, 2013

@daxter just acknowledging your comm so yo don't think i am ignoring you. I started a new, simple app for this example and it all worked nicely! Hmm, it must be one or more of the other features that have been added to the original project - when I have found the combo that produces this anomaly I will post it here. (work on it tonight, will have a post for you within next 24hrs)

@seanlinsley
Copy link
Contributor

No worries :)

@themi
Copy link

themi commented Aug 1, 2013

Here is the demo app https://github.com/themi/demo

It was the clockwork gem that is clashing.

CC @tomykaira
CC @leomao10

@omerpucit
Copy link

It should work in this way

if Rails.env == "development"
  activeadmin_reloader = ActiveSupport::FileUpdateChecker.new(Dir["app/models/**/*"]) do
    ActiveAdmin.application.unload!
    Rails.application.reload_routes!
  end
  ActionDispatch::Callbacks.to_prepare do
    activeadmin_reloader.execute_if_updated
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests