Hi. I''m trying to monkey patch the rails_admin gem. First, I tried to add a file in config/initializers containing: RailsAdmin::MainController.class_eval do def get_sort_hash CODE HERE... end end It was only loaded once, and then the method from the gem was always executed instead of mine. I also tried to add the code in lib/ with the correct line in config/application.rb to load all files in lib/. But in this case it does not work at all. Each time I defined my method using the following blocks: RailsAdmin::MainController.class_eval do end ::RailsAdmin::MainController.class_eval do end Any idea? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/R-GP-E-bR8wJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Jul-06 19:23 UTC
Re: Monkey patching a gem (rails_admin, with Rails 3)
On Jul 6, 4:40 pm, Michel Pigassou <dag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi. > > I''m trying to monkey patch the rails_admin gem. >Not entirely answering the question, but why not just fork it on github? Bundler makes it super easy to install gems from your own git repo Fred> First, I tried to add a file in config/initializers containing: > RailsAdmin::MainController.class_eval do > def get_sort_hash > CODE HERE... > end > end > > It was only loaded once, and then the method from the gem was always > executed instead of mine. > > I also tried to add the code in lib/ with the correct line in > config/application.rb to load all files in lib/. But in this case it does > not work at all. > > Each time I defined my method using the following blocks: > RailsAdmin::MainController.class_eval do end > ::RailsAdmin::MainController.class_eval do end > > Any idea? Thanks.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michel Pigassou
2011-Jul-07 07:55 UTC
Re: Monkey patching a gem (rails_admin, with Rails 3)
You''re probably right, but I would not lose rails_admin features. But as nobody answered my problem on the plugin''s mailing list I think I''m gonna try other backend tools. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/cV-aI9mUuXwJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Jul 6, 2011 at 8:40 AM, Michel Pigassou <dagnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi. > > I''m trying to monkey patch the rails_admin gem. > > First, I tried to add a file in config/initializers containing: > RailsAdmin::MainController.class_eval do > def get_sort_hash > CODE HERE... > end > end > > It was only loaded once, and then the method from the gem was always > executed instead of mine. > > I also tried to add the code in lib/ with the correct line in > config/application.rb to load all files in lib/. But in this case it does > not work at all. > > Each time I defined my method using the following blocks: > RailsAdmin::MainController.class_eval do end > ::RailsAdmin::MainController.class_eval do end > > Any idea? Thanks. >What are you trying to do exactly? -Conrad> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/R-GP-E-bR8wJ. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michel Pigassou
2011-Jul-07 09:40 UTC
Re: Monkey patching a gem (rails_admin, with Rails 3)
I want to be able to sort a view of a model that has nested belongs to: Checkin belongs to a Program that belongs to a User So I want to sort the checkins according to the linked users. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/nzPQtQgH8VQJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michel Pigassou
2011-Jul-07 11:21 UTC
Re: Monkey patching a gem (rails_admin, with Rails 3)
OMG I feel ashame, I discovered that what I want to do at the relationship level can be done with a has_one :through... Never thought of using this! BTW I modified the admin_data plugin to tweak the sorting order and add scopes, could be useful for other nested associations. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/17itcR_oO4IJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.