ruby-on-rails-5.2

Cannot load Rails.config.active_storage.service

不羁岁月 提交于 2021-02-18 20:49:19
问题 I'm setting up a new rails 5.2 app utilising Active Storage and using AWS for the hosting of images in production. However, I'm having an issue with the app reading the credentials: 2018-07-06T08:11:52.625415+00:00 app[web.1]: ! Unable to load application: Aws::Sigv4::Errors::MissingCredentialsError: Cannot load `Rails.config.active_storage.service`: 2018-07-06T08:11:52.625432+00:00 app[web.1]: missing credentials, provide credentials with one of the following options: 2018-07-06T08:11:52

Rails Simple Form input with Font-Awesome

我的梦境 提交于 2021-01-29 08:17:06
问题 I want to use icons instead of text for labels in a horizontal simple_form. However, I am unable to separate the text from the icons = simple_form_for @user, html: { class: 'form-horizontal' }, wrapper: :horizontal_form do |f| # shows 'username' label only = f.input :username # shows icon with 'username' = f.input :username, label_html: {class: "fas fa-user"} # shows nothing = f.input :username, label_html: {class: "fas fa-user"}, label: false 回答1: You can use the wrapper_html option: = f

Remove Coupon from Stripe Subscription in Update

◇◆丶佛笑我妖孽 提交于 2021-01-28 11:18:24
问题 I need to remove a coupon on a subscription during update, I thought passing coupon of nil to the api should remove it, but it just removes it from the post. There is another way of doing it like this.. https://stripe.com/docs/api/discounts/subscription_delete but it requires another call I don't want to do. Ruby Stripe Gem API: Stripe::Subscription.update( subscription.stripe_id, { coupon: nil, items: [ { id: subscription.item_stripe_id, quantity: 0, }, { plan: to_plan.stripe_id, quantity: 1

Configuring ActiveStorage to use S3 with IAM role

生来就可爱ヽ(ⅴ<●) 提交于 2020-08-24 09:17:26
问题 I'm trying to configure ActiveStorage to use S3 bucket as a storage backend however I don't want to pass any of access_key_id , secret_access_key , region . Instead, I'd like to use previously defined IAM role. Such configuration is mentioned here. It reads (I've added bold): If you want to use environment variables, standard SDK configuration files, profiles, IAM instance profiles or task roles, you can omit the access_key_id, secret_access_key, and region keys in the example above. The

Dangerous query method deprecation warning on Rails 5.2.3

浪尽此生 提交于 2020-08-04 05:22:30
问题 I am in the process of upgrading my Rails app to 5.2.3 I am using the following code in my app. MyModel.order('LOWER(name) ASC') It raises the following deprecation warning: DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "LOWER(name)". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe

Dangerous query method deprecation warning on Rails 5.2.3

让人想犯罪 __ 提交于 2020-08-04 05:21:08
问题 I am in the process of upgrading my Rails app to 5.2.3 I am using the following code in my app. MyModel.order('LOWER(name) ASC') It raises the following deprecation warning: DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "LOWER(name)". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe

How can i get url of my attachment stored in active storage in my rails controller

蓝咒 提交于 2020-05-14 18:09:05
问题 How can i get url of my has_one model attachment stored in active storage in my rails controller. So, that I would be able to send it as full link as api in json. So far, I have tried following methods but each of them are giving various issues: 1) current_user.image.service_url ---- undefined method `service_url' for # 2) Rails.application.routes.url_helpers.rails_disk_blob_path(current_user.image, only_path: true) , it gives me an output like: "/rails/blobs/%23%3CActiveStorage::Attached:

How can i get url of my attachment stored in active storage in my rails controller

六月ゝ 毕业季﹏ 提交于 2020-05-14 18:08:13
问题 How can i get url of my has_one model attachment stored in active storage in my rails controller. So, that I would be able to send it as full link as api in json. So far, I have tried following methods but each of them are giving various issues: 1) current_user.image.service_url ---- undefined method `service_url' for # 2) Rails.application.routes.url_helpers.rails_disk_blob_path(current_user.image, only_path: true) , it gives me an output like: "/rails/blobs/%23%3CActiveStorage::Attached: