All Questions

279
votes
5answers
68639 views

What is the difference between <%, <%=, <%# and -%> in ERB in Rails?

Can some one please describe the usage of the following characters which is used in ERB file: <% %> <%= %> <% -%> <%# %> what's the usage of each one ?
289
votes
6answers
215926 views

raw vs. html_safe vs. h to unescape html

Suppose I have the following string @x = "<a href='#'>Turn me into a link</a>" In my view, I want a link to be displayed. That is, I don't want everything in @x to be unescaped and dis...
37
votes
3answers
31119 views

Disable HTML escaping in erb templates

In a Rails 3 application I have a domain class where one attribute stores pure HTML content (it's a blog app, the domain class is Post). In the ERB templates, I need to display the content of the at...
22
votes
8answers
61916 views

How to pass a javascript variable into a erb code in a js view?

I have this Javascript view in my Rails 3 project: app/views/expenses/new_daily.js.erb var i = parseInt($('#daily').attr('data-num')) + 1; //$('#daily').append('agrego fila ' + i + ' <br />');...
18
votes
3answers
13549 views

Rails js.erb file cannot find method "render"

I've got the following code in a Javascript ERB file: $(document).ready(function() { $("#workout-week").append( <%= escape_javascript(render :partial => "show_training_period", :locals =&...
25
votes
4answers
40195 views

Rails 3 render action from another controller

I need to render another controller action <%= render "controller/index" %> and i get this error Missing partial controller/index with {:formats=>[:html], :locale=>[:en, :en], :handlers=>[:...
50
votes
9answers
45346 views

Ruby templates: How to pass variables into inlined ERB?

I have an ERB template inlined into Ruby code: require 'erb' DATA = { :a => "HELLO", :b => "WORLD", } template = ERB.new <<-EOF current key is: <%= current %> curr...
203
votes
5answers
57488 views

Best way to add comments in erb

What is the best way to add comments in erb files, if we do not want them to be generated into the html content?
101
votes
6answers
51894 views

What is the meaning of erb?

Why is the view of Rails application in the format *.erb.html? What does "erb" mean?
28
votes
5answers
21872 views

erb in coffee script with rails 3.1

I would like to use some erb in my .coffee files, like the following example myLatlng: new google.maps.LatLng(<%=@location.latitude %>, <%=@location.longitude %>) I renamed my locations...

Previous Next