Reputation: 4830
Rails has 607 open issues...so, rather than plugging that hole even more I though Id try here first. I have upgraded to 4.1 and am implementing rails mailer previews. I tried upgrading my existing mailer and adding tests/mailers/previews directory. When that gave the following error I tried generating a new mailer. Same error.
class NotifierPreview < ActionMailer::Preview
def welcome
Notifier.welcome(User.first)
end
end
results in this error:
The action 'notifier' could not be found for Rails::MailersController
I've tried searching google, the docs, stack overflow, but nothing eludes to this error.
Anyone experience this or have any ideas?
Upvotes: 29
Views: 11386
Reputation: 2442
If you're using rspec, make sure that the rspec-rails
gem is being loaded in the development environment, otherwise Rails will look for the previews under the /test folder, not /spec.
Upvotes: 6
Reputation: 1084
The default preview path is /test/mailers/previews
but rspec will override this to be /spec/mailers/previews
You can set the path to be whatever you like with:
config.action_mailer.preview_path = "#{Rails.root}/test/mailers/previews"
Upvotes: 82
Reputation: 2533
Remove the line(s)
get '/:controller(/:action(/:id))'
get '/:controller(/:action(/:id))(.:format)'
from your routes.rb
As @hellion says in a comment on the previous answer this is the solution to this problem.
Upvotes: 4
Reputation: 8065
This is because you are using UserMailer
with NotifierPreview
. Change NotifierPreview to UserMailerPreview and it will start working. Check the example implementation https://github.com/RichIsOnRails/ActionMailerPreviewsExample and tutorial.
Cheers!!
Upvotes: 7