erb

Rails: syntax error, unexpected keyword_ensure, expecting $end

回眸只為那壹抹淺笑 提交于 2019-12-22 08:33:51
问题 I'm creating a very basic rails app (learning tutorial) and can't understand why I'm getting this error. I've tried troubleshooting but to no avail. My code: <ul class = "nav pull-right"> <% if user_signed_in? %> <li><%= link_to current_user.full_name, edit_user_registration_path %></li> <li><%= link_to "Log Out", destroy_user_session_path, method: :delete %></li> <% end %> <% else %> <li><%= link_to "Log In", new_user_session_path %></li> <li><%= link_to "Sign Up", new_user_registration_path

Why is Rails giving me “Can't verify CSRF token authenticity” error?

蓝咒 提交于 2019-12-22 04:35:17
问题 I am getting a "Can't verify CSRF token authenticity" in Rails production. My questions are: Why is it doing this? How can I fix it? Here's my Heroku logs (some values anonymized): 2016-02-13T01:18:54.118956+00:00 heroku[router]: at=info method=POST path="/login" host=[MYURL] request_id=[ID STRING] fwd="FWDIP" dyno=web.1 connect=0ms service=6ms status=422 bytes=1783 2016-02-13T01:18:54.116581+00:00 app[web.1]: Started POST "/login" for [IPADDRESS] at 2016-02-13 01:18:54 +0000 2016-02-13T01:18

Pass Rails JSON variable to javascript variable

我怕爱的太早我们不能终老 提交于 2019-12-22 03:22:26
问题 I have a Global JSON variable in my Ruby on Rails controller. It looks like this @rails_side_json = { :name => 'Will', :age => 23 }.to_json I want this to be assigned to my javascript variable ( var javascript_side_json ) which resides in my javascript file named custom.js.erb The value in javascript_side_json variable after the assignment is done should be equivalent to me writing var javascript_side_json = {"name": "Will", "age": 23 }; I am not able to achieve this by writing var javascript

How to get YAML files to render in middleman with erb

允我心安 提交于 2019-12-22 00:15:00
问题 I have a file written in yaml that I would like to render with middleman using erb. How do I render this so that the yaml file will be translated to HTML. I would later like to style it using CSS. I have found no information of how to do this basic task online anywhere. For example say I have the yaml file: main_title: 'Ruby Operators' sections: - section_title: 'Arithmetic' items: - title: '[ + ] Addition: ' value: 'Adds values on either side of the operator' - title: '[ − ] Subtraction: '

Rails: Setting a value to input field if variable exists

蹲街弑〆低调 提交于 2019-12-21 19:45:47
问题 I'm trying to set a value to two text field inputs when an id is passed to the new action in the controller. The current code works but I'm wondering if the code can be shortened. Current code View <div class="custom-input"> <% if @debtor %> <input type="text" name="debtor_name" class="form-control" id="debtor-search-form" value='<%= @debtor.name %>'> <% else %> <input type="text" name="debtor_name" class="form-control" id="debtor-search-form"> <% end %> </div> <% if @debtor %> <%= f.text

how to test the result of applying a puppet template to given test parameters

此生再无相见时 提交于 2019-12-21 17:26:54
问题 I have the following puppet template file solr.json.erb: { "servers" : [ { "port" : "<%= jmx_port %>", "host" : "localhost", "queries" : [ <% @markets.each do |market| -%> { "outputWriters" : [ { "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter", } ], "obj" : "solr/market_<%= market %>:type=queryResultCache,id=org.apache.solr.search.LRUCache", "attr" : [ "hits","hitratio"] }, <% end -%> ], "numQueryThreads" : 2 } ] } and I want to test the result of applying the template to some

application.css not being served as an asset

ぃ、小莉子 提交于 2019-12-21 09:11:31
问题 EDIT 4, 5 and 6 8 hours in, any more ideas are welcome :) Maybe this bug is already known and solved, but I get the behaviour I described in edit 2&3, when you have this in a .css.erb file in app/assets/stylesheets : li { background-image: url(<%= asset_path "logo_80px_80px.png" %>); } The problem part seems to be the asset_path method call, but .css.scss also breaks it with: li { background-image: url(image-path("logo_80px_80px.png")); } My GemFile is: source 'http://rubygems.org' gem 'rails

In Rails, how can I allow some html in a text area?

…衆ロ難τιáo~ 提交于 2019-12-21 07:36:06
问题 I have a Rails app (blog) that I am creating. Very basic stuff. In my content area I have a text area for the content of the post. I am needing to include some html in the text area (links, formating, etc). <%= f.text_area :content %> Is there another tag that I can use instead of text_area, that will allow me to do this? 回答1: Have you tried this in the views? <%= content.html_safe %> 回答2: This is an old question but I guess there's a pretty straight forward view helper for this: sanitize . I

Rails if statement syntax

血红的双手。 提交于 2019-12-21 07:02:50
问题 I've written the following ERB and am getting a syntax error at the question mark. This helper function from devise currently evaluates as false. What have I missed? <%= if user_signed_in? %> <%= render 'form' %> <%= end %> 回答1: Try this : <% if user_signed_in? %> <%= render 'form' %> <% end %> If you do <%= ... %>, it will try to output the thing you put between the tags. But, if you do <% ... %>, then no output is processed, just the code is evaluated. If this is not working, then there is

Library to parse ERB files

徘徊边缘 提交于 2019-12-21 05:40:37
问题 I am attempting to parse, not evaluate, rails ERB files in a Hpricot/Nokogiri type manner. The files I am attempting to parse contain HTML fragments intermixed with dynamic content generated using ERB (standard rails view files) I am looking for a library that will not only parse the surrounding content, much the way that Hpricot or Nokogiri will but will also treat the ERB symbols, <%, <%= etc, as though they were html/xml tags. Ideally I would get back a DOM like structure where the <%, <%=