ruby-on-rails-5.1

Rails: Improve performance of simple searching method

拈花ヽ惹草 提交于 2019-12-24 20:28:22
问题 I have been building an app these days. The functionality is nothing fancy at all, I have to connect to a client's SOAP webservice, fetch some data, save it into my pg database and build a search functionality based on this data. The search has to be performed on two tables, both combined are like 80K rows. It needs to look for every word in the input text in several fields from these two tables, which have a classical assocation one to many. Previous to get my hands dirty I was looking at

The asset “logo.png” is not present in the asset pipeline

杀马特。学长 韩版系。学妹 提交于 2019-12-23 06:47:39
问题 In Rails 5.1.3 I change logo file in app/assets/images Then error don't know what to fix. Any one know ? The asset "logo.png" is not present in the asset pipeline. Already try restart rails, rails clean, rails or rails assets:precompile Here my config/initializers/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

Rspec request specs and Rails 5

元气小坏坏 提交于 2019-12-21 04:51:12
问题 I'm starting a new project, my first with Rails 5.1.0. I have a pb with my first request spec. describe 'Users', type: :request do it 'are created from external data' do json_string = File.read('path/to/test_data/user_data.json') params = { user: JSON.parse(json_string) } headers = { "CONTENT_TYPE" => "application/json" } expect do post '/api/v1/users', params.to_s, headers end.to change { User.count }.by(1) expect(response.status).to eq 200 end end this spec return the error ArgumentError:

Testing POST ActionDispatch::Http::Parameters::ParseError: 765

瘦欲@ 提交于 2019-12-21 04:05:11
问题 It says there's an unexpected token in my params. "ActionDispatch::Http::Parameters::ParseError: 765: unexpected token at 'conversation_identifier[participant_list][]=2&conversation_identifier[participant_list][]=1" A version of the test with magic numbers for clarity: let(:headers) do { 'HTTP_CURRENT_USER_ID' => 2, 'Content-Type' => 'application/json' } end let(:params) { { conversation_identifier: { participant_list: [1, 2] } } it 'is getting testy' do post resource_url, params: params,

Rails 5.1: “unknown firstpos: NilClass” - Issue reloading application

别说谁变了你拦得住时间么 提交于 2019-12-20 09:26:57
问题 Following an upgrade from Rails 5.0 to 5.1 I'm getting this error anytime the app reloads, either from code changes during rails server or if I call reload! from the console. 🌶 13:53$ rc Loading development environment (Rails 5.1.1) 2.3.1 :001 > reload! Reloading... ArgumentError: unknown firstpos: NilClass from (irb):1 2.3.1 :002 > https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/journey/gtg/builder.rb Application Trace is empty, here's the Framework Trace:

Rails Webpack fingerprinting not working as intended

允我心安 提交于 2019-12-13 03:49:27
问题 I've been using mostly vanilla Webpack configuration with Vue.js. I've been trying to trackdown what broke it, but my fingerprinting doesn't seem to work well anymore. Everytime I update one of the components, a pack would get reloaded, as you'd expect. The problem is that on production, browser doesn't seem to know about it anymore. So it will try to use the old pack, not find it and crash my app. Only by clearing the cache to make it download all packs again, it will get the pack with the

How to store string as array in database column using Ruby on Rails

僤鯓⒐⒋嵵緔 提交于 2019-12-11 17:51:48
问题 This question is asked many times on SO. The main problem is nothing got fits into my situation. Case is, I am not able to store typed content as array in database column. text_field whose code is: = text_field_tag 'product[keywords][]', @product.keywords, class: 'tab-input product_keywords' In controller strong parameters are: params.require(:product).permit(:id, :name, :keywords => []) Jquery code that is not not removing value upon deletion when typed wrong value but it add commas after

install with Yarn bootstrap@4.0.0-alpha.6 on rails 5.1

血红的双手。 提交于 2019-12-10 15:49:42
问题 I'm following this tutorials for install Bootstrap with Yarn this was the command for the new version of Bootstrap 4 on rails 5.1 who watch here: yarn add bootstrap@4.0.0-alpha.6 So I notice it was installed the bootstrap 4 alpha 6, JQuery3 and Tether. So it was already added on .gitignore the: /node_modules /yarn-error.log And was already Set up in my config/initializers/assets.rb Rails.application.config.assets.paths << Rails.root.join('node_modules') I need to put on my application.js //=

How to turn off BIGINT primary keys in Rails 5.1

元气小坏坏 提交于 2019-12-10 15:10:37
问题 Rails 5.1 migrations generates BIGINT (instead of Integer ) for tables' primary keys (changelog). Is it possible to disable that somewhere in the config? If so, how to do disable it? 回答1: According to pull request, no this is not possible on config level. But you can, in fact, force id to be integer, like this: create_table :users, id: :integer do On the other hand, you must be aware that changes also affected references behavior, so you should be careful with those: t.references :orders,

rails - Displaying image in view after uploading a file via Active Storage

穿精又带淫゛_ 提交于 2019-12-10 12:49:36
问题 I have a project that is on rails 5.1.2 and I am trying to implement Active Storage on it, following couple of tutorials online I am able to setup the Active Storage and I can see the data being saved inside the active_storage_blobs and active_storage_attachments table. Tutorial 1 Tutorial 2 I also confirmed by running user.avatar.attached? and in response I got true so things are working. What I am having problem with is displaying an image in view, I have tried <%= image_tag(url_for(user