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

Make gem available on Rails 4 #2

Open
dtrounce opened this issue Sep 10, 2013 · 4 comments
Open

Make gem available on Rails 4 #2

dtrounce opened this issue Sep 10, 2013 · 4 comments

Comments

@dtrounce
Copy link

Would it be possible for this gem to work with Rails 4? RIght now I get:

Bundler could not find compatible versions for gem "rails":
In Gemfile:
devise_sms_activable (>= 0) ruby depends on
rails (~> 3.0.0) ruby

rails (4.0.0)
@giano
Copy link
Owner

giano commented Sep 10, 2013

I really think this gem would work on rails 4, but latest commit dropped to 3.0 version. I think they are upgrading it. On my side the code is quite simple, and should be 4 ready. But I must admit I'm quite out of Rails scene actually. You can test changing manually gemspec file.

@dtrounce
Copy link
Author

Thanks, I forked the code and set 'rspec-rails' => '~> 2.5.0'. I can now install the gem. But when I configure and try to use it (with Twilio), I get "wrong number of arguments (0 for 1)".

I've traced this down to devise_sms_activable / lib / devise_sms_activable.rb, where we have:

Get the sms sender class from the mailer reference object.

def self.sms_sender
@@sms_sender_ref.get
end

Set the smser reference object to access the smser.

def self.sms_sender=(class_name)
@@sms_sender_ref = ActiveSupport::Dependencies.reference(class_name)
end

self.sms_sender = "Devise::SmsSender"

But ActiveSupport::Dependencies.reference("Devise::SmsSender").get fails, as get expects the argument "key" - but none are provided to get in sms_sender. This causes the wrong number of arguments error when you call Devise.sms_sender

I'm at the limit of my understanding here. Any ideas? Get doesn't look like it has changed in Rails 4 vs. 3.

@zsy056
Copy link

zsy056 commented Apr 22, 2014

In activesupport-4.10/lib/active_support/dependency.rb, I find out that ClassCache::get actually takes one argument:

def get(key)
  key = key.name if key.respond_to?(:name)
  @store[key] ||= Inflector.constantize(key)
end

So, I think that error comes from a call to this method.
Then I modify the code in lib/devise_sms_activable.rb to

def self.sms_sender
  @@sms_sender_ref.get 'Devise::SmsSender' 
end

At this time, I get an error undefined constant Devise::SmsSender, after I move lib/devise_sms_sender.rb to lib/devise/sms_sender.rb and add config.autoload_paths += %W(#{config.root}/lib) to mine config/application.rb, everything works fine...

@Feuda
Copy link

Feuda commented Jul 31, 2014

when bundle install

Bundler could not find compatible versions for gem "rails":

In Gemfile:
devise_sms_verifiable (>= 0) ruby depends on
rails (~> 4.0.3) ruby

 rails (4.1.4)

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

4 participants