简体   繁体   中英

Site move to Rails - partials

I'm moving my site to Rails currently.

Beforehand I used jQuery load() method to insert a separate site html element. Now moving to Rails, I have to change it. From what I've learnt so far, the best way here is to use a Rails partial for this purpose. Is this correct?

I would recommend taking a read through the Ruby on Rails Guides which are extremely helpful if you are just getting started in Rails. The specific section that might help is their documentation on using partials .

Yes, you are correct. Partials come in handy when you want to load some HTML elements conditionally, or want to reuse them in different places. A prime example for that is the footer or header of a website. Instead of writing the code in all the required files, simply render the partial wherever required. For further reading/implementation guide, you can refer the section on partials in the RoR guide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM