How do I set up emails on Spree Commerce? - ruby-on-rails

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!

Related

Modifying Rails gems

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

How can I alter a gem on heroku?

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

What is the best way to test Action mailer without worrying about the enviroment-rails 3

i need to test the action mailer in my ruby on rails project which is already live.i don't want to go in the mess of creating a new mail server like zimbra on localhost or mess with the configurations of the other environments that i have.moreover i cant think of looking in the log files which will be a complete height of patience.is there any other way to check/debug action mailer in localhost.if yes then how and if not then why not?
Several alternatives:
define an interceptor in development, see this railscast
use letter_opener gem to see the mail instead of actually sending it, link to gem

what are the steps to using ruby gem guard-shopify

I am currently creating a theme on Shopify and found a ruby gem called guard-shopify. I am struggling to use the gem. It is installed and i got to the point of adding the api key and secret password but now I am struggling to find out how to go about editing theme files locally and getting it to work with guard shopify so it pushes the most recent changes to the shopify account via guard.
Does anyone have good experience using this ruby gem?
Thanks,
Mark
try the shopify_theme gem - it has a watch option - https://rubygems.org/gems/shopify_theme

devise and invitable plugin : how do you set the invitation_limit

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.

Resources