Is it possible to render a view file from another website?
I am using Ruby on Rails 3 and I would like to know if it is possible to render a view file (a partial template) from another RoR applicatio开发者_如何学Pythonn (anotherr website). If so, and if the view contains a form, it is possible to submit that form sending information over HTTPS?
Yes.
Here is how you might do it.
Create a symlink from the controller's view folder to the partial in the other application.
ln -s path_to_existing/_existingPartial.html.erb path_to_referring/_existingPartial.html.erb
You can now reference the existingPartial in your views as if it were in the same application.
The form will work as long as the target of the form posts to a valid URL in your current directory.
That said, this isn't the best way to do this. A couple other options:
- Create a Rails plugin both apps use
- Create a Gem both apps use
- Depending on your source control software, you can reference the same file in both source trees (for example, using Subversion external references)
Rails supports rendering an arbitrary file
render "/old_app/current/app/views/pages/show"
精彩评论