Questions tagged [ruby-on-rails-5]

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

Ruby on Rails 5 is the previous major revision of Ruby on Rails, "an open-source web framework that's optimized for programmer happiness and sustainable productivity."

Multiple sub-versions have been released, namely 5.1 and 5.2. Questions regarding specific sub-versions of Ruby on Rails 5 can also be asked on the appropriate tags:

Resources:

See also:

9415 questions
23
votes
7 answers

How do you send JSON data in a rails-ujs Rails.ajax POST call (not using jQuery)?

I have a React client app that needs to talk to a Rails API. I want to use the rails-ujs method Rails.ajax. For example: Rails.ajax({ type: "POST", url: "/things", data: mydata, success: function(response) {...}, error: function(response)…
Hrishi Mittal
  • 1,455
  • 10
  • 15
23
votes
2 answers

skip_before_action and Rails 5

I just upgraded to Rails 5 and everything went pretty smoothy but for no apparent reason a method that is called after skip_before_action is not allowing rspec to run with this message Before process_action callback :redirect_heroku_user has not…
Bitwise
  • 8,021
  • 22
  • 70
  • 161
23
votes
3 answers

What is the difference between `stream_from` and `stream_for` in ActionCable?

The descriptions here seem to imply that stream_for is used only when passing in a record, but overall the documentation is rather vague. Can anyone explain the differences between stream_from and stream_for and why would you use one over the…
Xavier
  • 3,423
  • 23
  • 36
23
votes
4 answers

Rails 5, "nil is not a valid asset source"

I have just upgraded to Rails 5 and I have a weird issue while trying to show an image. I have the exact code I had for Rails 4: <%= image_tag article.image_url(:thumb) %> But after upgrading I get: nil is not a valid asset source Before upgrading…
Tasos Anesiadis
  • 1,134
  • 1
  • 12
  • 37
23
votes
10 answers

Send auth_token for authentication to ActionCable

module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect #puts params[:auth_token] self.current_user = find_verified_user logger.add_tags 'ActionCable',…
alxibra
  • 727
  • 1
  • 7
  • 12
23
votes
2 answers

How to use ActionCable as API

I built a very simple app using Rails 5 beta 1 and ActionCable to show when users come online and let them send messages to each other. Now, I would basically like to take the client-side part of ActionCable, implement it in the context of another…
sam
  • 1,711
  • 1
  • 17
  • 24
23
votes
3 answers

What’s does the [5.0] in Rails 5’s ActiveRecord::Migration mean?

A migration I created in a Rails 5 application had 5.0 passed into a method: class CreateVariableKeys < ActiveRecord::Migration[5.0] ... end I would like to know what the [5.0] means.
gnerkus
  • 11,357
  • 6
  • 47
  • 71
22
votes
1 answer

Rails Activestorage + DirectUpload javascript progress bar not showing when using "remote:true"

I have been using Rails ActiveStorage DirectUpload in my Rails app. And here is the code of the form:

Select Files To Upload

<%= form_for @uploader, url: uploaders_file_path(@uploader), :html => {:multipart => true} do |f| %> <%=…
22
votes
8 answers

Yarn install says up to date, yet can't start rails console

I've been developing an app using Webpack, Vue.js and Rails. No problems for two months, but out of nowhere when I try to start rails console rails c, yarn complains that packages out of date: error An unexpected error occurred: "Unknown language…
Maxim Fedotov
  • 1,349
  • 1
  • 18
  • 38
22
votes
1 answer

Use Rails 5.2 ActiveStorage to create and save pdf and later attach to email

I am afraid i am getting something completely wrong with the new active storage feature. What I want to do is to create an pdf ( I am using WickedPdf ) and attach it to a model. Here is the first issue, The only chance i figured out so far is to…
22
votes
3 answers

Set local: true as default for form_with in Rails 5

I'm working on a project where we won't be using ajax calls for submitting the forms, so I need to put local: true in every form in the project, as indicated in the rails docs: :local - By default form submits are remote and unobstrusive XHRs.…
Ramses
  • 996
  • 4
  • 12
  • 28
22
votes
4 answers

Adding custom parameters to devise registration - unpermitted parameters

I've been trying to customize the devise register method to register with more parameters and also update more(no luck so far), but I always get Unpermitted parameters: error. I tried using this Adding extra registration fields with Devise and…
Bogdan Daniel
  • 2,689
  • 11
  • 43
  • 76
22
votes
3 answers

Rails: Why do I get "warning: already initialized constant JSON::VERSION" when running rake cucumber?

I've just set up a Linux Mint box for rails development with rvm. I went ahead and generated a Rails 5 app, set up the mysql connection, added the cucumber-rails gem and then tried to run: rake cucumber For some reason, I was met…
Micah Gideon Modell
  • 586
  • 1
  • 9
  • 24
22
votes
2 answers

Puma Rails 5 binding.pry only available for 60 seconds before timeout

Puma times out my request when I'm using binding.pry. In my controller def new require 'pry' binding.pry end I then make a request that hits the controller and enter the pry session. After 60 seconds Puma? times out my request, restarts a…
thedanotto
  • 6,895
  • 5
  • 45
  • 43
22
votes
9 answers

How to upload a file in a Rails Rspec request spec

I want to test uploading a file in a Rails Rspec request test. I'm using Paperclip for asset storage. I've tried: path = 'path/to/fixture_file' params = { file: Rack::Test::UploadedFile.new(path, 'application/pdf', true) } post…
hirowatari
  • 3,195
  • 2
  • 14
  • 15