Questions tagged [ruby-on-rails-5.1]

For issues specific to the version 5.1 of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].

Ruby on Rails 5.1, "an open-source web framework that's optimized for programmer happiness and sustainable productivity." Rails 5.1 brings a bunch of new features and improvements over older Rails versions.

Major Features

  • Yarn Support
  • Webpack
  • Encrypted secrets

See Ruby on Rails 5.1 Release Notes for more information.

Resources

Related tags

397 questions
3
votes
1 answer

Rails 5.1: retrieve records for nested association with includes

I'm trying to implement includes in has_many / belongs_to association similar to this example: class Author < ApplicationRecord has_many :books, -> { includes :line_items } end class Book < ApplicationRecord belongs_to :author has_many…
matiss
  • 747
  • 15
  • 36
3
votes
0 answers

How do you test a file generator in a rails 5 gem with rspec

I'm completely new to testing, but I want to learn and I am having trouble with using Rspec to test a gem I created. The gem just creates a new folder with two files in a desired location. How do I test that the files were created and in the proper…
Luke Popwell
  • 381
  • 1
  • 3
  • 15
3
votes
2 answers

Using multiple class in image_tag helper in ruby on rails

How do I pass multiple classes to the image_tag helper in a Rails 5 app? I want to convert this HTML tag: into <%= image_tag @post.picture.url if @post.picture?…
Shofi
  • 41
  • 5
3
votes
0 answers

Cookies not working Rails 5.1.1

I have this message in the browser when I open it. I'm using Rails 5.1.1, ruby 2.4.1, puma 3.9.1. "undefined method `signed' for nil:NilClass" referring to cookies.signed I have the same project in Rails 5.0.3 and it's working. I've commented the…
3
votes
0 answers

Rails 5.1 app freezing on heroku deploy with Yarn

I'm deploying my first Rails 5.1 app to Heroku just now and seem to be coming up against a brick wall with Yarn. When I try to deploy, it freezes at the same stage each time. It will do this for 30minutes or longer, by which point I get bored and…
bodacious
  • 6,608
  • 9
  • 45
  • 74
3
votes
4 answers

Heroku CI w/ Postgresql Extensions

I'm attempting to use Heroku's CI to run my Rails application's tests but it's running into a problem when attempting to load my structure.sql file. -----> Preparing test database Running: rake db:schema:load_if_ruby …
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
2
votes
2 answers

How to get the last entered record field in rails with join and group by?

I am using rails 5.1 with ruby 2.4 and I am stuck in rails Active record query, which I have already made it in SQL but not able to replicate it in the rails way. Please suggest the right syntax, thanks in advance. The Sql query is: select jobs.id,…
vidur punj
  • 5,019
  • 4
  • 46
  • 65
2
votes
1 answer

How to get Checkbox value in ruby on rails

I want to get checkboxs values in order to set parameters of an http request to a restful API. I am new to web development and I am having troubles with ruby on rails 5.1 Basically, I have two views: - one where you can check/uncheck two checkboxs…
2
votes
1 answer

Rails 5.0 to 5.2: how to migrate schema.rb

After updating my gems, I'm not being able to run rails db:schema:load. The error reported is: ActiveRecord::MismatchedForeignKey: Column `user_id` on table `user_applications` has a type of `int(11)`. This does not match column `id` on `users`,…
2
votes
1 answer

Rails 5 Api Only with React Native New Session Id Each Time

React Native V 0.56 for Android Rails 5.1.3 API Only My Rails app was able to persist session, but suddenly after upgrading React Native to 0.56 the Rails is creating a new session every time on each api request. Unable to understand why the…
red-devil
  • 1,064
  • 1
  • 20
  • 34
2
votes
3 answers

Rails 5.2 Encrypted credentials for production environment

I have created the new Rails app with the version of 5.2. Rails 5.2 introduced the encryption feature for the secrets. I have configured the secret key in devise.rb file config.secret_key =…
Aravind
  • 1,080
  • 2
  • 12
  • 18
2
votes
0 answers

rails will_save_change_to strange behavior

I've come across a strange situation updating a rails 4.2 app to 5.1. For debugging purposes I have removed everything from the user model, it is now completely empty standard model: class User < ActiveRecord::Base end I'm having problems with…
Chad
  • 768
  • 1
  • 6
  • 20
2
votes
1 answer

Rails 5.1.6 issues with assets

I recently installed rails 5.1.6 but when I go to any one of the views in an application, it throws the following error. Errno::ENOENT in Test#index No such file or directory @ unlink_internal -…
xploited
  • 36
  • 4
2
votes
1 answer

Rails 5 before_destroy callback: with prepend or without fails

I know that in Rails 5 before_destroy callback does not take into account false return value but throw(:abort) instead. You can find more about it here and there and in Rails API docs. But prepend option still does not work in the following…
belgoros
  • 3,590
  • 7
  • 38
  • 76
2
votes
2 answers

Rails 5 API - How to respond with HTML on a specific controllers as an exception?

I have Rails API app. And 99% of the routes are JSON routes. however, I want to add one single route that will response with HTML. How can I do that? This is my current setup and when I browse the route I see a string of HTML tags on the…
Ilya Libin
  • 1,576
  • 2
  • 17
  • 39