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.
Related
So I know I can install the mailer gem from here:
https://guides.spreecommerce.com/user/configuring_mail_methods.html
But it clearly says that generic action mailer settings are more favourable at the top of the page.
I have installed postmark which is sending emails fine in an extension I built. However Spree does not appear to be sending emails when I create an order for a customer. How can I turn these transactional emails on without the Spree mailer gem, as I want to use postmark on its own.
Also where the hell is the listed email section from the documentation?
https://guides.spreecommerce.com/developer/deployment_tips.html
Thanks for any help!
You can set up emails by adding the gem at https://github.com/spree-contrib/spree_mail_settings
Not sure if the message at the top of the page has been changed since this question was posted but it says to use that gem now.
Add gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings' to you gemfile and you will get a new page in the admin settings for setting up your email
An update for those facing this issue in 2021:
It's not recommended to use this gem. Instead, use a standard rails configuration: https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
This guide on how to fix extensions for Spree 4+ may also come in handy: https://guides.spreecommerce.org/developer/contributing/upgrading_extensions.html
If anyone is desperately in need of this extension, feel free to submit a pull request!
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
ok I'm using sorcery gem for the log in of the main engine.
And I want to use it also in the main engine but whenever I call the user model in the
mountable engine it says
undefined method `authenticates_with_sorcery!' for User:Class
When I said call it's like
#user = User.new
By the way I'm using mongoid 4.0.0 and rails 4.1
I ran into similar issues using MongoMapper. Try making sure that authenticates_with_sorcery! appears beneath any of your database-related includes. For example:
class User
include Mongoid::Document
authenticates_with_sorcery!
end
In my case, the gems order in the gemfile was apparently wrong
Not good
gem 'sorcery'
gem 'mongoid'
Works!
gem 'mongoid'
gem 'sorcery'
As far as I remember when I posted this question sorcery gem doesn't support Mongoid 4 yet so they make a new branch in the github so that for those who are using Mongoid in that time can use sorcery with mongoid 4. Well basically the solution works for me is that I need to reference that branch in my Gemfile. I don't know right now if they already publish the latest sorcery gem.
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
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