Subham93
Subham93

Reputation: 633

How to include html files in rails?

I am new to rails and wanted to know what are some of the ways to include html files in rails- from public folder, from views folder or any other method if any.

Upvotes: 2

Views: 6753

Answers (3)

Ryosuke Hujisawa
Ryosuke Hujisawa

Reputation: 2872

stop thinking and use jQuery

html

  <div id="here"></div>

jquery

<script>
    $('#here').html("<%= j(render partial: 'profiles/users') %>");
</script>

Upvotes: 0

Stepan Parunashvili
Stepan Parunashvili

Reputation: 2845

In Rails, You put your view files in app/views/controller_name/action_name.html.erb

Take a look at this to get a better understanding -- http://blog.codinghorror.com/understanding-model-view-controller/

Also consider doing the Rails Tutorial(Hartl), that should get you started in understanding how the framework works.

Update

Change your header.html, and rename it to _header.html.erb

in your action_name.html.erb,

write

<%= render 'header' %> 

the _ denotes that it's a partial

Upvotes: 2

sreenivas
sreenivas

Reputation: 395

@file = render_to_string :file => '/aboslute/path/to/file.html'

Upvotes: 0

Related Questions