erb

$ is not defined within a .js.erb view using Webpack 2 in Rails app

浪子不回头ぞ 提交于 2019-12-14 03:46:02
问题 I'm migrating from assets pipeline to Webpack 2 in a Rails 4 app. Everything seems to work fine, except for the JS code using jQuery within a .js.erb view. The content of the webpack.config.js is as follows (omitted code for fingerprinting and compression): const path = require('path') const webpack = require('webpack') const ExtractTextPlugin = require('extract-text-webpack-plugin') const jsOutputTemplate = 'javascripts/[name].js' const cssOutputTemplate = 'stylesheets/[name].css' module

Unable to create/generate a stripe_card_token

天大地大妈咪最大 提交于 2019-12-14 03:25:53
问题 I am creating a stripe_card_token with: Stripe.createToken(card, charge.handleStripeResponse) In my charges.js.coffee file jQuery -> Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content')) charge.setupForm() charge = setupForm: -> $('#new_charge').submit -> $('input[type=submit]').attr('disabled', true) if $('#card_number').length charge.processCard() false else true processCard: -> card = number: $('#card_number').val() cvc: $('#card_code').val() expMonth: $('#card_month').val

How can I convert erb to html?

强颜欢笑 提交于 2019-12-13 14:48:01
问题 Imagine in rails I have @template that is an instance of ActionTemplate::View . Question is: How can I convert @template whose @template.source is <%= "hello from erb" %> to hello from erb ?? thanks 回答1: Try this... ERB.new(@template.source).result ERB#new 回答2: Well... messing around with ActionView::Template.new outside of Rails is not really recommended. You need a ton of stuff setup beforehand (init and render) If you do want to just use ERB, then go with this example require 'erb' x = 42

How to change the color of link button in .erb template

纵然是瞬间 提交于 2019-12-13 10:01:04
问题 I want to change the color of the "Explore" and 'Submit Your project" button in the erb template .Currently they are blue coloured .If Shoud i use a div to do this or is there any other way too <div id="header"> <%= link_to 'Explore', explore_path %>                                                                                      <%= link_to 'Submit Your Project', submit_path %> <div class="wrapper clearfix"> <h1 id="lockitron_header"><a href="/"><%= Settings.product_name %></a></h1> <

How to replace a pattern in a string

跟風遠走 提交于 2019-12-13 09:47:17
问题 I built a page that is rendered differently depending on params . The logic is something like this: <% if params[:x] == "1" %> <!--render version A--> <% elsif params[:x] == "2" %> <!--render version B--> <% elsif params[:x] == "3" %> <!--render version C--> <% end %> I want each version to have two links which link to the other two versions, so the urls should have different params. I have a url string original_url , which is: "localhost:3000/page?x=1" and want to replace its parameter

rails-Bootstrap-markdown gem not parsing to html on save

早过忘川 提交于 2019-12-13 09:14:15
问题 I am using bootstrap-markdown to add a markdown editor to my page and save the content parsed to html in the database. The problem is that (although i believe it should) it does not save the html result but the raw text instead. this is my code: <div class="well col-md-10 col-md-offset-1"> <%= form_for(:post, :url => {:action => 'create'}) do |f| %> <%= f.text_field(:title, class: 'form-control')%> <%= f.text_field(:description, class: 'form-control')%> <%= f.text_area(:content, rows: 15,

File Not Found Error When Changing style.css.scss to style.css.scss.erb

假如想象 提交于 2019-12-13 08:24:43
问题 I have been having a lot of trouble getting my background images to show up when I deploy my rails app to Heroku. I finally found this in the Heroku documentation: In Rails 4 sprockets will only produce digest filenames. This means that you must use an ERB helper such as this to reference your assets: <%= asset_path('logo.png') %> Make sure to add a .erb extension to any files in app/assets that use an ERB helper. So application.css would need to be application.css.erb. I tried renaming the

Why does my erb code result in timestamps when tutorial doesn't? [duplicate]

风流意气都作罢 提交于 2019-12-13 06:10:13
问题 This question already has answers here : What is the difference between <%, <%=, <%# and -%> in ERB in Rails? (7 answers) Closed 4 months ago . I'm doing the Getting Started with Rails guide at http://guides.rubyonrails.org/getting_started.html and I'm up to the last section of 5.8. My output contains this additional line and I can't figure out where it comes from. Can someone help me out? [#<Article id: 1, title: "Test", text: "tests", created_at: "2017-01-17 20:01:14", updated_at: "2017-01

Implementing a OnClick kind of functionality and formatting wrt Rails Partial-Views

你。 提交于 2019-12-13 05:39:56
问题 I am trying to implement a functionality similar to the onclick method of Javascript, using Rails Helpers. I have implemented a auto complete feature for more than one field in Rails 2.0.2 and Ruby 1.8.7. This configuration is run on Ubuntu 10.04 and yes , I know.. you might feel why Rails 2.x when we have Rails 3.x , it is so because of project specific purposes. I don't have much of a choice on that ..:) . I am able to successfully retrieve a group specific profile pic, a group title and a

what is the equivalent of “data-hover:” in a ruby on rails' link_to block

断了今生、忘了曾经 提交于 2019-12-13 04:39:51
问题 I have the following html <a href="#" data-hover="Seraglio"><span>Seraglio</span></a> How do I convert it to RoR ? 回答1: Syntax: link_to(body, url, html_options = {}) So for your example, in .erb format : <%= link_to("#", {"data-hover" => "Seraglio"}) do %> <span>Seraglio</span> <% end %> Docs: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to 回答2: You may do it this way:- link_to(body, url, :data =>{:hover => your_data_hover_value}) 来源: https:/