For example, I have a lot of similar pages. With only one difference: on each of this page (they have different controller) they have different variable, what apply to this html.erb file.
For example, video post html.erb
<% for post in @posts_for_video>
here some html
and javascript
and also ruby code injection
<% end %>
Video controller:
@posts_for_video = Post.where(photo: true)
And my photos page:
<% for post in @post_for_photos >
same html as video
same js as video
and same ruby code as video
<% end %>
Photo controller:
@posts_for_photo = Post.where(video: photo)
So my question: Is there any possibility to put html+js+ruby_code to, for example application_controller.rb
?
I think, what I'm looking for is (in application_controller.rb):
def posts_for_all(post_variable)
for post in post_variable
html: post.theme
js: post.animation
ruby: some methods
end
end
Aucun commentaire:
Enregistrer un commentaire