we're working on our opensource password manager cryptopus https://github.com/puzzle/cryptopus.
since our last release we integrated emberjs and are updating one component after another from classic rails webapp to emberjs. For now, we used locationType: "hash" to trigger emberjs parts.
one challenge we're facing now is to make sure the URLs are still the same after moving the UI components to emberjs. So we should get rid of "hash"-URLs for emberjs and still be able to call some legacy rails webapp URLs.
is there a way to ignore routes in emberjs and sending the request to the backend? any other ideas to make an incremental integration of emberjs possible? It would be OK if the SPA would be re-initialized after coming back from an class rails webapp URL.
some example routes:
/session/new -> send to rails backend
/teams -> handle by emberjs
/teams/42 -> handle by emberjs
/admin/users -> send to rails backend
it would be also possible to add a prefix for all emberjs handled routes like: /app/teams, /app/teams/42
we found a pretty simple solution for the problem.
in config/environment.js: removed rootURL, locationType: "auto"
configured all required routes in emberjs
created an frontend controller in rails which serves the ember files on first request
so now, some frontend parts of the app run with ember, others still with rails. the ember router doesn't care about URLs that are not configured. Pretty nice solution :)
have a look at https://github.com/puzzle/cryptopus to see the complete solution.
Related
I've been rebuilding a rails site with an Angular front end.
Is there an angular-way to do emails? I was trying to send them through the rails server, but now all my rails url helpers are screwed up by the difference between the angular url routes and the rails API routes. Do I use angular? Do I use rails url helpers somehow? Or do I manually update each route with this gnarly pattern:
Link to Post
Thanks!
I have an existing website written in jsp. I want to rewrite a part of the website. The url for that section can either be newpart.mysite.com or mysite.com/newpart.
Will it be possible to rewrite this new part in Ruby on Rails? How does the routing works for both the url options.
Yes, you can use ROR for a portion of your site.
If your using a webhost they will route the domain to a folder on your server.
The way you worded your question, it seems as if your "newpart" will be a separate interface than the rest of the code for your site. You can act as if they are on different servers basically.
Yes you can do that.
For your options:
If you point the whole subdomain at rails: newpart.mysite.com, then all you have to do is tell apache (or whatever you use) to redirect that URL to your RoR app - and the app will happily continue from there without any changes to routing.
It would be more complex if you wanted to use: mysite.com/newpart ... so if you have a choice, I'd go with the subdomain.
One project based on emberjs and rails.
When redirect to localhost/#lessons/2, the page works
when redirect to localhost/practices/2#/lessons/2,
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
so what's the difference between 'localhost/#lessons/2' and 'localhost/practices/2#/lessons/2'
If want to make 'localhost/practices/2#/lessons/2' works, how to set emberjs route?
so what's the difference between 'localhost/#lessons/2' and 'localhost/practices/2#/lessons/2'
Difference is the /practices/2 part. That's part of the url's path. By default ember will ignore that, it's just paying attention to the hash, which in bot cases is lessons/2.
Like firefox says, seems like the server is redirecting the request.
If want to make 'localhost/practices/2#/lessons/2' works, how to set emberjs route?
Hmmm... that url implies that server/rails is responsible for rendering practices/2 and that you have an ember app on the practices/2 page which should be rendering lessons/2? It's possible but that sounds like a very complicated setup. I'd be surprised if that's what you really want. Probably instead you will want to have localhost/#practices/2/lessons/2. With that setup just use normal ember routing as described here: http://emberjs.com/guides/routing/defining-your-routes/
Does anybody know of a good example I could look at as to how to go about implementing authentication through backbone with rails?
I haven't been able to find anything..
You have several possibilities. First you can log in normally, with plain html. That login would guide you to your backbone.js application.
Another possibility is within your backbone.js app you have a login form that takes advantage of backbone.js's ":authentication_token". When your backbone.js app sends the login info it will get a token back. From then on you are able make ajax calls and receive responses with that token.
EDIT: see this post for an example of working with the token: http://www.hyperionreactor.net/blog/token-based-authentication-rails-3-and-rails-2
What you are looking about rails integration with client-side, except ajax queries and authentication/authorization?
Use the demo app to see how backbone.js is working: http://documentcloud.github.com/backbone/examples/todos/index.html
Found one example app. Trying to figure out what is what atm myself. But might be worth looking: https://github.com/diaspora/diaspora
I've gone round and round trying to come up with the cleanest / easiest way to write request specs for certain pages of my site. I basically need a way to get Capybara to load pages that only accessible over https. Here are the pertinent details:
I'm currently using RSpec, Capybara and FactoryGirl on Rails 3.1.0
Its an e-commerce site. Some controllers force all actions ssl using the new force_ssl method in the controller class definition while some do not. I need the cart and checkout pages to be always https://, of course, while the rest of the site should remain accessible over http://.
I would be OK with somehow stubbing the SSL aspect of the requests if only I knew how to do it!
I'm sure many people out there have faced this same challenge. How did you do it?
What Capybara driver are you using? It should work fine with Selenium.