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

Custom templates #1

Closed
eugenebolshakov opened this issue Jan 6, 2010 · 7 comments
Closed

Custom templates #1

eugenebolshakov opened this issue Jan 6, 2010 · 7 comments

Comments

@eugenebolshakov
Copy link

Hi guys,

The README says that it's possible to specify your own custom template for the notifier, but I'm not sure how exactly that can be done given that the notifier's template_root is set to lib/../views and it seems to be trying to load templates from there.

I guess it's possible to specify a relative path as a workaround if you have mail_form installed as a plugin, but in case of gem it won't work.

I wonder if I'm missing something and if you guys use this feature yourself.

Thanks!

@josevalim
Copy link
Contributor

You should and can change the template root to point to your app/views:

MailForm.template_root = Rails.root.join("app", "views")

You can copy mail_form original template and add any you want.

@eugenebolshakov
Copy link
Author

Thanks, Jose! That makes sense.

Btw, I guess you wanted to say

MailForm::Notifier.template_root = File.join(Rails.root, "app", "views")

I've put that in config/initializers/mail_form.rb

@josevalim
Copy link
Contributor

Yes!

Rails.root.join("app", "views")

The above should work also, since Rails.root returns a Pathname.

@eugenebolshakov
Copy link
Author

While Rails.root.join("app", "views") correctly joins the parts, it doesn't work for specifying view paths, because of the way ActionView::PathSet works (it assumes that if it gets something that's not a string, then it's a view path object, but in this case it's Pathname). At least not in the rails version I'm using.

@josevalim
Copy link
Contributor

A-ha! Maybe we would need to append .to_s, but good to know this gotcha. Thanks!

@eugenebolshakov
Copy link
Author

Yep, Rails.root.join("app", "views").to_s would work perfectly

@acrolink
Copy link

I cannot locate this file: config/initializers/mail_form.rb.

Kindly explain how to customize the template in latest releases (where there is no config/initializers/mail_form.rb file).

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants