Note that there are some explanatory texts on larger screens.

plurals
  1. PORAILS_ROOT_VIEW_PATH Constant, like RAILS_ROOT?
    primarykey
    data
    text
    <p>Is there an answer to the following SAT-style analogy?</p> <pre><code>. : RAILS_ROOT :: ./app/views : ??? </code></pre> <p>I.e., is there a constant in Rails for the path <code>app/views</code>?</p> <p>The reason I'm asking is because from <code>app/models/notifier.rb</code>, I'm trying to render the body of an email with a file:</p> <pre><code> def notify_fact_act(user, domain, filename) subject "Email with multipart/alternative &amp; attachment" recipients user.email from "rails@example.com" content_type "multipart/mixed" file = File.join(view_paths.last, mailer_name, @template+'.text.') body = {:user =&gt; user, :domain =&gt; domain} part :content_type =&gt; "multipart/alternative" do |p| p.part :content_type =&gt; "text/plain", :body =&gt; render(:file =&gt; file + "plain.erb", :body =&gt; body) p.part :content_type =&gt; "text/html", :body =&gt; render(:file =&gt; file + "html.erb", :body =&gt; body) end attachment :content_type =&gt; "application/pdf", :body =&gt; File.read(filename), :filename =&gt; File.basename(filename) end </code></pre> <p>Note: the reason I'm doing explicit template rendering is that the <a href="http://apidock.com/rails/ActionMailer/Base" rel="nofollow">ActionMailer::Base documentation</a> states, "Implicit template rendering is not performed if any attachments or parts have been added to the email," and I'm adding a PDF attachment.</p> <p>Also, from the debugger, I find that <code>view_paths.last</code> gives me what I want, but it seems variable. I want something constant that I know will work every time.</p> <p>Also, from the debugger, I can type <code>p instance_variables</code> &amp; <code>p.local_variables</code>, but I don't see a method (in the output of <code>p puts methods.sort</code>) for printing out the available constants. Is there one?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload