rubygems

How to override a class method of the gem in rails Application?

六眼飞鱼酱① 提交于 2019-12-17 23:39:38
问题 Best practice to Override a class method of the gem in rails Application ? . I need to override the behaviour of the find method of a gem. following is the code in the gem module Youtube class display attr_accessor :base def find(id, options = {}) detailed = convert_to_number(options.delete(:detailed)) options[:detailed] = detailed unless detailed.nil? base.send :get, "/get_youtube", options.merge(:youtube_id => id) end end end How do i override the above find method in my YoutubeSearch

Rails 3 generators in gem

徘徊边缘 提交于 2019-12-17 23:28:23
问题 Might sound like a simple question, but I'm stumped. I've created a gem that essentially contains a generator. It contains the following structure: lib - generators - my_generator my_generator_generator.rb (see below) - templates my_template_files... - my_generator.rb (empty file) test -test files GemFile etc.. However when I add this Gem to my gem file and run rails g, it's not listed. Is there any additional config that I need to do? My generator roughly looks like this... class

How to use ActiveAdmin on models using has_many through association?

不打扰是莪最后的温柔 提交于 2019-12-17 22:29:09
问题 I am using ActiveAdmin gem in my project. I have 2 models using has_many through association. The database schema looks exactly the same as the example in RailsGuide. http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association (source: rubyonrails.org) How can I use ActiveAdmin to ... show appointment date of each patient in physicians page? edit appointment date of each patient in physicians page? Thanks all. :) 回答1: For 1) show do panel "Patients" do table_for

How can I call an older version of a gem from the commandline?

允我心安 提交于 2019-12-17 21:53:49
问题 Say I have two versions of a gem installed (somegem versions 0.10.6 and 0.10.5) and I want to run the earlier version from the commandline. Do I have to uninstall the newer version? Is there a way I can use a flag to specify which version I want to use? Something like... somegem /path/to/dir --version 0.10.5 I checked the rubygems documentation, and it only describes how to use a specific version when you require a gem from a file, but nothing about how to do it from the commandline. 回答1:

Where to override current_user helper method of devise gem

对着背影说爱祢 提交于 2019-12-17 21:53:45
问题 How can i override current_user of devise gem. Actually I need to add web services for mobile-app. Currently devise is managing session and 'current_user' for web-application. Now Mobile app will send user_id to the server. I need to override current user like this def current_user if params[:user_id].blank? current_user else User.find(params[:user_id]) end end Should I need to modify devise gem as plugin ? or something else ? Kindly explain in detail as I am new in rails. Kind regards, 回答1:

Ubuntu rails install fails on zlib

被刻印的时光 ゝ 提交于 2019-12-17 21:26:15
问题 I've just moved over to Ubuntu 8.10 as my dev box; it's my first serious foray into Linux as a daily-use OS, and I'm having a hard time getting Rails going. I have followed a number of tutorials which all seem to work fine, but when I try and use gem install or gem update on anything, I get an error that looks like this: /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError) from /usr/local/lib/ruby/site_ruby/1.8

How do I fix Rubygems recent deprecation warning?

狂风中的少年 提交于 2019-12-17 18:28:51
问题 I have recently run updates: gem update --system gem update Now, I come with a lot of deprecation warnings each time I load a gem. For example, rails console : NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10. NOTE: Gem::Specification#default_executable= is deprecated with no replacement.

How to remove gem from Ruby on Rails application?

元气小坏坏 提交于 2019-12-17 17:47:10
问题 I have installed a gem on my Rails application (devise). After I installed the gem, I realized that I don't need it. I want to remove the gem, its dependencies and the files it created on my application. In other words, I want to restore the system to what it used to be before the gem. How can I do this? (I'm using Ruby on Rails 3.) 回答1: Devise uses some generators to generate views and stuff it needs into your application. If you have run this generator, you can easily undo it with rails

Ruby Gemspec Dependency: Is possible have a git branch dependency?

扶醉桌前 提交于 2019-12-17 17:42:12
问题 Is possible have a git branch dependency, inside mygem.gemspec? I'm thinking something similar to the following: gem.add_runtime_dependency 'oauth2', :git => 'git@github.com:lgs/oauth2.git' ... but it doesn't work. 回答1: This is not possible, and likely never will be because it would be rather heavy-handed for RubyGems to allow gem developers to require that users have a specific version control system installed to access a gem. Gems should be self-contained with a minimal number of

BUG Bus Error ruby 1.8.7

不羁的心 提交于 2019-12-17 17:38:24
问题 I'm getting an error after compiling Ruby 1.8.7 using RVM on Lion 10.7.1 with Xcode 4.2 GM (new MacBook). It compiles fine but when I try to install any gem I get the following: gem install bundler /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Bus Error ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0] Abort trap: 6 Update : In the end I hope to have Xcode 4.2 installed, RVM with Ruby 1.8.7, 1.9.x installed and all working properly. 回答1: Since I had to parse