Andrew
2012-Feb-28 19:35 UTC
Conditional execution of javascript / embedding Cappuccino files into Rails
I have a Cappuccino app that I am integrating with a Rails backend. A
key feature of the app is authentication which is managed entirely by
rails. The way I set it up is that the cappuccino js conditionally
executes if the user is logged in, like this:
<% if signed_in? %>
<div id="cappuccino-body">
<script type="text/javascript">
document.write("Hello World")
</script>
</div>
<% end %>
Where signed_in? is a rails method that returns a boolean value
reflecting whether the user is authenticated.
The issue I am having is when I embed the scripts to launch Cappuccino
into an erb page, I get 404 errors because Rails cannot find the
associated files. I tried putting them into /vendor/assets and /public
with no luck in either case. Does anyone know the right location for
these files? Or is this a routing issue and I need to update my routes
file?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Andrew
2012-Feb-28 19:58 UTC
Re: Conditional execution of javascript / embedding Cappuccino files into Rails
I fixed the issue, it turns out that putting everything in a directory inside Public was messing it up. Once I changed my references to account for that, everything worked. On Feb 28, 11:35 am, Andrew <abari...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a Cappuccino app that I am integrating with a Rails backend. A > key feature of the app is authentication which is managed entirely by > rails. The way I set it up is that the cappuccino js conditionally > executes if the user is logged in, like this: > > <% if signed_in? %> > > <div id="cappuccino-body"> > <script type="text/javascript"> > document.write("Hello World") > </script> > </div> > > <% end %> > > Where signed_in? is a rails method that returns a boolean value > reflecting whether the user is authenticated. > > The issue I am having is when I embed the scripts to launch Cappuccino > into an erb page, I get 404 errors because Rails cannot find the > associated files. I tried putting them into /vendor/assets and /public > with no luck in either case. Does anyone know the right location for > these files? Or is this a routing issue and I need to update my routes > file?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Seemingly Similar Threads
- Action Controller Error: undefined local variable or method `current_user'
- Problem with undefined variable current_user
- I''m writing an article about Rails and I need help
- before_save :encrypt_password
- Devise is causing the [The change you wanted was rejected.] Error...