ruby-on-rails-5

Why does my stripe elements form not work on rails?

冷暖自知 提交于 2020-06-28 05:32:06
问题 I'm trying to get Stripe.js to work on my rails app. I am using stripe elements. I have followed the instructions on the stripe docs. The form card input is not showing up where it should. It just shows the submit button. I am trying to place the Stripe form in an existing rails form I have. <!DOCTYPE html> <html> <head> <title>Bennett</title> <%= csrf_meta_tags %> <%= csp_meta_tag %> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Update Active Storage attachment filename

余生长醉 提交于 2020-06-26 12:40:30
问题 I want to know how to update the filename of an Active Storage attachment. Here's what I'm trying now: 2.5.1 :052 > attachment.filename => #<ActiveStorage::Filename:0x00007fb2926cf6a0 @filename="example.pdf"> # at this point the filename is example.pdf 2.5.1 :053 > attachment.update!(filename: 'foo.pdf') (0.2ms) BEGIN Patient Load (0.5ms) SELECT "patients".* FROM "patients" WHERE "patients"."deleted_at" IS NULL AND "patients"."id" = $1 LIMIT $2 [["id", 40861], ["LIMIT", 1]] (0.2ms) COMMIT =>

Where are Rails helpers available?

坚强是说给别人听的谎言 提交于 2020-06-25 18:43:10
问题 I'm referring to the modules you create in app/helpers . Are they available in: Views? Controllers? Models? Tests? Other files? Sometimes? All the time? 回答1: In Rails 5 all Helpers are available to all Views and all Controllers, and to nothing else. http://api.rubyonrails.org/classes/ActionController/Helpers.html These helpers are available to all templates by default. By default, each controller will include all helpers. In Views you can access helpers directly: module UserHelper def

Where are Rails helpers available?

风流意气都作罢 提交于 2020-06-25 18:42:50
问题 I'm referring to the modules you create in app/helpers . Are they available in: Views? Controllers? Models? Tests? Other files? Sometimes? All the time? 回答1: In Rails 5 all Helpers are available to all Views and all Controllers, and to nothing else. http://api.rubyonrails.org/classes/ActionController/Helpers.html These helpers are available to all templates by default. By default, each controller will include all helpers. In Views you can access helpers directly: module UserHelper def

Rails 5 Assets Not Loading in Production

心不动则不痛 提交于 2020-06-25 04:14:13
问题 I recently updated a few packages in my Rails application and now my assets aren't being served. Instead, I get the following error: Failed to load resource: the server responded with a status of 404 (Not Found) My assets are precompiled: assets.rb # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails

Rails ActiveStorage scope for when file is attached

做~自己de王妃 提交于 2020-05-27 04:43:41
问题 When using ActiveStorage, how do you create a scope for when files are attached. For example: class Check < ActiveRecord::Base has_one_attached :image end I want something like Check.has_attached_image to return only records where there is an existing attached image. I know that ActiveStorage provides a with_attached_image scope. But that doesn't seem to be working: irb(main):009:0> Check.with_attached_image.to_sql => "SELECT \"checks\".* FROM \"checks\"" 回答1: Main purpose of the scope with

Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?

落花浮王杯 提交于 2020-05-25 21:12:11
问题 I am getting issues while setup and run the docker instance on my local system with Ruby on Rail. Please see my docker configuration files:- Dockerfile FROM ruby:2.3.1 RUN useradd -ms /bin/bash web RUN apt-get update -qq && apt-get install -y build-essential RUN apt-get -y install nginx RUN apt-get -y install sudo # for postgres RUN apt-get install -y libpq-dev # for nokogiri RUN apt-get install -y libxml2-dev libxslt1-dev # for a JS runtime RUN apt-get install -y nodejs RUN apt-get update #

Rails using puma, change localhost:3000 to localhost:3000/example

浪子不回头ぞ 提交于 2020-05-15 20:40:22
问题 I have developed a rails 5 application that works fine in http://localhost:3000/ Now, I need that this application starts in localhost:3000/example, and that links goes through this new host, (localhost:3000/example/users/new for example). I have got that assets and javascripts works fine in localhost:3000/example with: config.root_path = '/example' but links still redirects to the old one (for example, localhost:3000/users/new). Anyone know how can I fix it? Thanks in advance 回答1: wrap your

How do you render HTML tags in React with Coffeescript?

喜欢而已 提交于 2020-05-15 09:41:51
问题 I'm currently learning ReactJS and how to work with Ruby on Rails as its backend, so I apologize if I'm making dumb assumptions, feel free to scold me. I'm following a tutorial where the author is using Coffeescript instead of ES6 to handle his ReactJS code. He provides an example component similar to this (coffeescript): @Rows = React.createClass render -> React.DOM.div className: 'rows' React.DOM.h1 className: 'title' 'Rows' This has two errors. The first one pertains to React.createClass

In Rails 5, setting config.active_record.schema_format = :sql but still getting schema.rb created on db:migrate

浪尽此生 提交于 2020-05-15 04:33:46
问题 Working on a Rails 5 app, I want to use structure.sql instead of schema.rb (we're using PostGIS with lots of custom SQL calls...). In config/initializers/database_options.rb I have the following: # use structure.sql, not schema.rb Rails.application.config.active_record.schema_format = :sql If I run the following: $ rake db:migrate it generates db/schema.rb , not db/structure.sql . The rails guides say: There are two ways to dump the schema. This is set in config/application.rb by the config