I recently deployed my app to heroku. It uses Devise, which I had to alter the after_sign_up_path so it would redirect correctly to a set page after someone signs up. This works fine locally, but when I deploy on heroku it installs the original unmodified devise gem.
Does anyone know of a way to modify a gem on heroku, or to make it use the modified gem in my vendor folder?
Thanks.
So, in general, it shouldn't be any different deploying your app on heroku than anywhere else.
One difference is that on heroku you're probably running in 'production' environment settings, and locally in 'development'. You can run in production locally too, if that were the issue.
But I don't think it is. When you say you "altered" Devise, do you mean you actually edited the source code inside the Devise gem source itself?
That's not a good practice. When a new version of Devise comes out, perhaps with security patches, what are you going to do? Re-customize the new version? It's not a great maintenance plan. If you really want to do this you can. The best way might be to create a fork of the Devise gem in a git repo (on github or anywhere else), customize that and commit your customizations to the repo, and then point to your customized version of Devise from your own git repo in your Gemfile with gem 'devise', :git => 'http://some.git.repo.clone.url.org'
But it's a bad idea.
Devise probably already supports your use case with configuration, rather than by editing Devise source code. Most experienced devs would consider that a much preferable way to accomplish what you want.
In this case, it looks like you should be providing an after_signup_path method override in your own local app, not modifying the default implementation in devise source. Google for more info, or consult the URL Finks provides in another answer, or post another question specifically asking how to do what you want to do with devise (it's actually nothing to do with heroku), being as specific as possible about what you want to accomplish.
Assuming you forked Devise to your github account, you can point your Gemfile to it by doing this:
gem "devise", :git => "git://github.com/user/devise.git", :branch => "my-awesome-branch"
By the way, I'd recommend you overwrite some devise methods rather than hack the gem but thats just my 2cents.
This may not answer your question but according to devise wiki, you don't have to alter the gem to get the redirect behavior you like, you just need to override the after_sign_in_path_for method in application controller. https://github.com/plataformatec/devise/wiki/How-To%3A-Redirect-to-a-specific-page-on-successful-sign-in-and-sign-out
Example:
def after_sign_in_path_for(resource)
current_user_path
end
Related
I am using tomichj/invitation for a project I'm doing, it has all the functionality I need, except it uses email. And there is no way to disable this email feature from it's config file.
How do I alter it so I can run the gem without it's email function, can I extend a gem's controller to bypass the email function entirely?
You could extend the gem's controller, yes. Another way to do it which would give you more control would be to fork the gem, alter it to remove the email function, and use your fork instead of the main gem. You'd have to pay attention to bugfixes in the trunk, but that shouldn't be a big issue.
You can easily open a gem by using the gem open <gemname> command.
So in your case, you can use gem open invitation. This will modify the installed gem directly. But be aware that updates will remove these modifications.
BTW if you want to use your preferred editor you can specify the EDITOR env variable.
E.g.: EDITOR=subl gem open invitation
I'm developing a Rails app. Cool.
I'm also having to develop a component as a Gem.
Basically, the Rails app use Omniauth to allow authentication from an OAuth2 service provider. However, NO strategy exist for this particular service provider, so I am writing one, and using my app to test it (they kind of need to be tested together). Unfortunately, Omniauth now REQUIRES strategies to be packaged as gems, and put into the Gemfile along with the omniauth gem.
So basically I'm wanting to put /my-new-strategy-gem with the strategy contents, IN my /myrailsapp folder, and then do gem "mystrategy" :as => "/myrailsapp", where inside /my-new-strategy-gem there is an actual gem, with gemfile, readme, etc.
The reason I'm asking here is that I tried this before, and Git would not recognize the /my-new-strategy-gem folder inside my main app folder, since it contains its own .git file and other info.
I've heard of making it a submodule, or ways that use the vender folder, and other things, so I'm wondering which approach works best in this situation.
Edit: The reason I wanted to do it this way, too, is so my coding partner who is helping with both, could clone a repo with both, all at once, and we could repackage the standalone strategy gem later.
You can use the :git attribute to point to the git repository for your gem.
http://gembundler.com/git.html
gem "my_strategy", :git => "git://github.com/rcd/my_strategy.git"
I believe you could also do this locally instead of on github.
I'm new to Rails and to Omniauth, so sorry in advance for the dumb
question.
I'm trying to do an Omniauth strategy for the Deezer website.
http://www.deezer.com/en/developers/simpleapi/oauth
First, I set up a basic rails application to test the Facebook strategy.
Here is my code in Github :
https://github.com/geoffroymontel/omniauth-test
And it works fine. Good.
Then I added those files in my app lib directory
lib/omniauth-deezer.rb
lib/omniauth/deezer.rb
lib/omniauth/deezer/version.rb
lib/omniauth/deezer/strategies/deezer.rb
and added
provider :deezer, ENV['DEEZER_APP_ID'],
ENV['DEEZER_APP_SECRET'], :perms => 'basic_access,email'
in
config/initializers/omniauth.rb
But when I start the app with
rails s
I get the following error message
/home/geoffroy/.rvm/gems/ruby-1.9.2-p290#rails3tutorial2ndEd/gems/omniauth-1.0.2/lib/omniauth/builder.rb:33:in `rescue in provider': Could not find matching strategy for :deezer. You may need to install an additional gem (such as omniauth-deezer). (LoadError) from /home/geoffroy/.rvm/gems/ruby-1.9.2-p290#rails3tutorial2ndEd/gems/omniauth-1.0.2/lib/omniauth/builder.rb:30:in `provider'
Thanks for your help
Best
Geoffroy
I added
require 'omniauth-deezer'
in initializers/omniauth.rb and it worked.
I don't really understand why I need it and Facebook doesn't.
In the Upgrading to 1.0 doc it is mentioned that Omniauth needs a gem for every provider now, so you'll have to move your provider to a gem eventually.
For future reference, if you want to add your own omniauth strategy, add this to your gemfile
gem 'omniauth-mystrategy', :path => '~/full-path-to-the-omniauth-folder/'
You´ll be using the local repository feauture of the gemfiles.
In the official bundler page you´ll see how to use remote repos also.
http://gembundler.com/v1.3/gemfile.html
Hi ive got devise and the invitable plugin working but Id like to set a default limit on how many people a user can invite.
According to the documentaion on github it mentions that you can set this number via invitation_limit
however ive tried using this in devises config file but it complains of undefined method.
I checked the source and theres definately an invitation_limit attribute being decremented. I tried adding this as an attribute to my users model but it still complains.
How do you setup this up????
My guess is that you are using the version of the devise_invitable gem that does not include "invitation_limit." You will need to use at least v0.4.rc5 to get all the new coolness that the documentation talks about. It's definitely a little confusing. Your Gemfile should look like this:
gem 'devise', '~>1.2.0'
gem 'devise_invitable', '~>0.4.rc5'
See here for a more in depth write-up about this issue with devise_invitable.
I've been trying to build my first rails app and have gotten stuck on the issue of user authentication. I've found a number of tutorials for using various plug-ins to do this, but so far every single one of them is out-dated, and as a result, broken!
From what I've read, I think Authlogic may be the best fit for me, and I've tried two things:
1) Going through Railscast, episode #160 (which is a tutorial for setting it up)
2) Using Ryan B's nifty_authentication gem with the --authlogic tag
In both cases, I get the following error as soon as I try to do anything with a user:
undefined local variable or method `acts_as_authentic' for #
I believe this is from the User model:
class User < ActiveRecord::Base
acts_as_authentic
end
I'm sure I've installed the authlogic gem, and I've added
config.gem "authlogic"
to my environment.rb
Any ideas about what's wrong? Anybody know of a complete and up to date tutorial for adding user authentication?
Edit:
I'm running Ruby v. 1.8.6 and rails v. 2.3.5
There is one thing that Ryan Bates in the RailsCasts episode doesn't talk about is about creating sessions table in your database. Type rake db:sessions:create in the console and run the migration rake db:migrate. Also like ghoppe says run rake gems:install after installing the gem. That is a requisite.
Here's an example app with a step-by-step guide - it's from last year but should still be mostly if not entirely accurate:
authlogic_example
Since you added that line to your environment.rb, have you tried rake gems:install to ensure the gem is installed and working correctly?
Also, what version of Ruby? What version of Rails? Have you tried running gem environment and gem list to make sure they're installed and running from the right place?
Another option is to use authlogic as a plugin, with:
script/plugin install git://github.com/binarylogic/authlogic.git
It also helps to look at a projects that uses authlogic as authentication module, like the fat_free_crm project, have a look at user.rb there
Last but not least, there is an active mailing list:
authlogic mailing list
Becoming popular is also the devise gem. Here you can add authentication with script/generate devise and you will have some views for login as well.
I forked that authlogic_example and added activity_tracker, authlogic, paperclip for user profile images, declarative_authorization, and user to user messages.
http://github.com/jspooner/authlogic_cucumber_rspec_example