ruby-on-rails-5

How to decrypt a Rails 5 session cookie manually?

我与影子孤独终老i 提交于 2019-12-18 05:57:10
问题 I have access to config.action_dispatch.encrypted_cookie_salt config.action_dispatch.encrypted_signed_cookie_salt secrets.secret_key_base the full cookie string (including -- ) I see ways to do this in Rails 4 (Rails 4: How to decrypt rails 4 session cookie (Given the session key and secret)), but these don't seem to work in Rails 5. 回答1: I have had the same problem the other day and figured out that the generated secret was 64 bytes long (on my mac), but Rails ensures that the key is 32

LoadError: Could not load the 'listen' gem (Rails 5)

最后都变了- 提交于 2019-12-17 22:46:05
问题 I've got an API mode Rails 5 app that won't let me run rake routes or rails s . The error I get is: $ rake routes rake aborted! LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile .../config/environment.rb:5:in `<top (required)>' LoadError: cannot load such file -- listen .../config/environment.rb:5:in `<top (required)>' Tasks: TOP => routes => environment (See full trace by running task with --trace) I've verified that listen is in the

issue deploying rails 5 application to AWS using Elastic Beanstalk due to rb-readline

╄→гoц情女王★ 提交于 2019-12-17 20:02:17
问题 I am trying to deploy my code to AWS using elastic beanstalk but keep running into errors when deploying. I added a gem 'rb-readline' and when I check the logs I see that there is an error with this gem in deployment. I can't remember what error adding the gem 'rb-readline' fixed but I don't know if removing the gem would fix this problem. Here is the link to the gem: https://github.com/ConnorAtherton/rb-readline here is the error log from the deployment. Application update failed at 2017-10

replace_gem: Error loading the 'sqlite3' Active Record adapter - while creating model

穿精又带淫゛_ 提交于 2019-12-17 18:53:08
问题 I am getting an error while creating a model in the created project and the error is as follows, /home/sushmitha/.rvm/gems/ruby-2.5.1/gems/bundler-2.0.1/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError) 回答1: For reference only following is added here, For

Rails 5: unable to retrieve hash values from parameter

走远了吗. 提交于 2019-12-17 15:49:09
问题 I'm running into a strange issue. undefined method `values' for #<ActionController::Parameters:0x007fb06f6b2728> is the error I get, when I assign a variable to a param hash, and try to get it's values. attributes = params[:line_item][:line_item_attributes_attributes] || {} attributes.values the parameter looks like this a hash of hashes: {"0"=>{"product_attribute_id"=>"4"}, "1"=>{"product_attribute_id"=>"7"}} now when I do this in console and assign that to a variable attributes it works

Rails 5: ActiveRecord OR query

人盡茶涼 提交于 2019-12-17 03:34:25
问题 How do you do an or query in Rails 5 ActiveRecord? Also, is it possible to chain or with where in ActiveRecord queries? 回答1: The ability to chain or clause along with where clause in ActiveRecord query will be available in Rails 5 . See the related discussion and the pull request. So, you will be able to do the following things in Rails 5 : To get a post with id 1 or 2: Post.where('id = 1').or(Post.where('id = 2')) Some other examples: (A && B) || C: Post.where(a).where(b).or(Post.where(c))

Rspec undefined method 'helpers' for ActionDispatch Routing

有些话、适合烂在心里 提交于 2019-12-14 03:54:10
问题 I'm upgrading an old rails 3 app to rails 5 and also upgrading Rspec in the process. When running test, I get an error: NoMethodError Exception: undefined method `helpers' for #<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007ffaf09d9200> whenever I call be_success on a response. See example: it "renders 'OK' text when request is html" do get :ping expect(response).to be_success response.body.should == 'OK' end I get the error when I run this test. After inserting a breakpoint, I

“Request has expired” when using S3 with Active Storage

大城市里の小女人 提交于 2019-12-14 03:49:04
问题 I'm using ActiveStorage for the first time. Everything works fine in development but in production (Heroku) my images disappear without a reason. They were showing ok the first time, but now no image is displayed. In the console I can see this error: GET https://XXX.s3.amazonaws.com/variants/Q7MZrLyoKKmQFFwMMw9tQhPW/XXX 403 (Forbidden) If I try to visit that URL directly I get an XML <Error> <Code>AccessDenied</Code> <Message>Request has expired</Message> <X-Amz-Expires>300</X-Amz-Expires>

Why does Rails 5 order test cases randomly?

不打扰是莪最后的温柔 提交于 2019-12-14 01:42:38
问题 It's mentioned in the upgrade guide Rails 5 will order tests randomly. It's trivial to revert to fixed order, but I'm just wondering why this change was made? Is it to support parallel testing? 回答1: Random test ordering is good practice. If you always do your test in a fixed order there is a chance your tests depend on each other. Each test should have no side effects, and random ordering guarantees this. 回答2: Refereed to Rails 5 Awesome features Rails 5 order test cases randomly, the new

Rails 5 - use collection_radio_buttons to open a partial with nested models?

做~自己de王妃 提交于 2019-12-13 20:28:33
问题 (my first SO question, so please be kind!) Each Schedule has only one System; Each System has many Applications; Each Application has many Users and Documents. What I want to do to create a Schedule entry: Generate a form that first shows multiple System names that can be clicked. When a System is clicked, it opens a partial that lists Applications associated with that System. Then, when clicking particular Applications, yet another partial opens that contains Users and Documents associated