ruby-on-rails-5

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

[亡魂溺海] 提交于 2020-05-15 04:33:20
问题 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

Rails 5 GET request nested array parameter changes unexpectedly

被刻印的时光 ゝ 提交于 2020-04-17 19:06:00
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

Rails 5 GET request nested array parameter changes unexpectedly

怎甘沉沦 提交于 2020-04-17 19:05:23
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

Rails 5 GET request nested array parameter changes unexpectedly

*爱你&永不变心* 提交于 2020-04-17 19:05:18
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

Rails Nesteds Forms with dynamic fields

自闭症网瘾萝莉.ら 提交于 2020-04-11 12:09:09
问题 Assuming I have a recipe table that has a field for name. The form would look something like this: <%= form_with(model: recipe, local: true) do |form| %> <%= form.text_field :name %> <%= form.submit %> <% end %> but if recipe is related to ingredients (which contains a name fields) through an intermediate table with the amount of the ingredient. how should i do the form to create a recipe, choose the ingredient and enter the amount of the ingredient. And also have the option to generate more

Best way to make Multi-Steps form in Rails 5 [closed]

試著忘記壹切 提交于 2020-04-08 18:19:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I have a standard form and there are few fields groups like main information, address, business address, etc. I'd like to build step-by-step form instead one-page form with a lot of fields. What is the best way to do that? I found https://github.com/schneems/wicked but I didn't

Rails 5.2 with master.key - Heroku deployment

一世执手 提交于 2020-04-08 00:57:50
问题 Rails 5.2 introduces the encrypted secrets feature through the usage of the awesome credentials.yml . But I'm struggling to get it to work with Heroku. Is there any Strategy available right now to deploy a Rails 5.2 App to Heroku? 回答1: You should set the environment variable RAILS_MASTER_KEY , either on your heroku web dashboard, or using console: $ heroku config:set RAILS_MASTER_KEY=<your-master-key> Example: $ heroku config:set RAILS_MASTER_KEY=123456789 (The < and > are placeholders) Rails

Rails - Show the users that a user started following in the last month

一笑奈何 提交于 2020-03-05 17:55:14
问题 Apologies for the question, I'm still learning rails. I'm trying to show in my html - all the users that a user has started following within the last month (i.e. recent users you've followed). I've tried two approaches-both unsuccessful. My first try was in my controller but the closest I got was showing users I've started following who were created in the last month. My second try was in my user model - but I get undefined method `call' for # Did you mean? caller following.html.erb <div

Gem::LoadError: can't activate mysql2 (< 0.5, >= 0.3.18), already activated mysql2-0.5.0

落花浮王杯 提交于 2020-03-03 12:51:13
问题 I did bundle install and the mysql2 gem was updated from 0.4.10 to 0.5.0. After this anything involving ActiveRecord blows up with the error in the title. 回答1: ActiveRecord only works with specific versions of mysql2. In your Gemfile add: gem 'mysql2', '< 0.5' and bundle install . I would also recommend adding a comment pointing to this URL so you know why the gem is pinned. 来源: https://stackoverflow.com/questions/49407254/gemloaderror-cant-activate-mysql2-0-5-0-3-18-already-activated-mysq

Gem::LoadError: can't activate mysql2 (< 0.5, >= 0.3.18), already activated mysql2-0.5.0

和自甴很熟 提交于 2020-03-03 12:50:47
问题 I did bundle install and the mysql2 gem was updated from 0.4.10 to 0.5.0. After this anything involving ActiveRecord blows up with the error in the title. 回答1: ActiveRecord only works with specific versions of mysql2. In your Gemfile add: gem 'mysql2', '< 0.5' and bundle install . I would also recommend adding a comment pointing to this URL so you know why the gem is pinned. 来源: https://stackoverflow.com/questions/49407254/gemloaderror-cant-activate-mysql2-0-5-0-3-18-already-activated-mysq