Questions tagged [ruby-on-rails-5]
For issues specific to version 5.0.x of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].
5,705 questions
0
votes
1answer
31 views
How to serialize nil to JSON as nil, not an empty place?
In my controller/action I have some values that are nil
def my_action
@var1 = get_boolean_value || nil
@var2 = get_int_value || nil
@var3 = get_string_value || nil
# there many more, any one ...
0
votes
2answers
22 views
Pagination is limiting my csv export
I have added csv export and pagination feature in my app.
parent.rb
CSV_HEADER = %w[parent_1_firstname parent_1_lastname address]
def self.to_csv
CSV.generate do |csv|
csv &...
0
votes
0answers
14 views
Rails form not passing value
I've got an error "Assignment must exist" when trying to submit a form which contain a file.
I passed the assignment params to the forms, check the strong params and still it ask for assignment_id. I ...
0
votes
2answers
34 views
Rails conditional association on instance itself
Let's say we have a Comment that is connected to an Article through a belongs_to association. Comment has an attribute called is_connected which is a boolean.
I know that it's possible to add a ...
0
votes
1answer
36 views
Setting up a has_many_through with separate database migrations rails 5
So I have the following functionality where I have courses, course modules and course exercises.
I have it where users can mark off modules once completed when all modules are completed the course ...
0
votes
1answer
23 views
rails http request with file on body
I am using trello api to attach an image to a card. the documentation says
require 'uri'
require 'net/http'
url = URI("https://api.trello.com/1/cards/id/attachments")
http = Net::HTTP.new(url.host, ...
0
votes
1answer
14 views
Convert Video to text(transcript) by google cloud speech to text with Rails Application
Working on a WebAppon Ruby on Rails.
I want to get subtitle for Pre recorded video and also for new videos going to record.
I have implemented the gem 'google-cloud-speech'.
But now I'm not able to ...
0
votes
0answers
27 views
Render Partial from Controller with local Form Builder variable?
I've got a Tags page that I want to add dynamic Aliases to. There's a link on the page to add a new Alias. I want this link to reload the partial I have with a form.fields_for to show all the current ...
-1
votes
1answer
89 views
+50
Rails loop in table by column and group
I'm looking to produce a looped table that has 3 results for each treatment. I want to one row to contain the date, degrees then list each individual treatment.
Controller
@trial = Trial.find(params[...
0
votes
0answers
14 views
Trying to get current_user in resolver
I have a use and project model. User has many projects. I am trying to understand Graphql.
I am using knock gem to authenticate. I am passing current_user in context from the graphql controller.
...
0
votes
1answer
18 views
DoubleRenderError but only one render
I have this
class ScriptsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
def run
@script.update(script_params)
Delayed::Job.enqueue ...
0
votes
1answer
50 views
Complete course and modules using Rails 5 assign to user
So this is a continuation of a previous question, however, this will stray off from the topic of that so here is a new one.
After this, I got roughly what I wanted to get working which is allowing ...
1
vote
0answers
30 views
Additional assets aren't compiled
In my application js/css file I have no "require_tree" directive. On some page I manually add additional scrip1.js and style1.css files by including them into a view. I've also added those files into "...
0
votes
1answer
13 views
Only show button if purchased Stripe
So I'm trying to have my app where when a user purchases a course they see a view modules button because when they purchase the course an order gets created so I'm checking whether an order exists.
...
0
votes
0answers
30 views
Using 2 separate databases in Rspec for testing libary
I have my Rails5 app with plenty of specs and these are running against postgres since my production/development is also postgres.
I developed some libary that lays in app/lib and definitely need ...
0
votes
0answers
29 views
fa fa spinner not displaying in the browser
I have a command like this in my index.html.erb
<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>
When i open the html in chrome the spinner is not displaying. I've tried with ...
0
votes
2answers
35 views
Ability: conditions dependent on the object (allow :create only for team_members)
Setup
A basic hotel setup where users are team members of a hotel. It uses cancancan and devise with Rails 5.2
rails g scaffold User name
rails g scaffold Hotel name
rails g scaffold TeamMembership ...
1
vote
0answers
18 views
Validation failing while submitting the form via Ajax
I have created a form with remote=>true option. Usually i use client side validation gem for handling errors. When i submit the form normally that is without ajax client-side validation is working ...
0
votes
0answers
10 views
Generate Documentation For Rails 5 REST API
Ideally I'm looking for a tool which generates API documentation from my rails application code, where the reader can play around with the endpoints. I saw swagger as a potential savior, but the most ...
0
votes
0answers
20 views
Rails - using Pundit with a separate admin namespace
I currently have Devise and Pundit working great in a closed system that requires a user be logged in to see anything.
The new goal: How can I use Pundit to require an AdminUser be logged in to ...
0
votes
2answers
39 views
Rails 5.2.1 - Model & Fragment Caching
I am trying to setup Model and Fragment Caching in Rails 5.2.1
I have had success with Fragment caching, but I am still seeing database queries after implementing model caching for my Model.
I have ...
0
votes
1answer
9 views
Try: gem pristine bootsnap --version 1.3.1 Ignoring bootsnap-1.3.1 because its extensions are not built. Try: gem pristine bootsnap --version 1.3.1
rails generate acts_as_votable:migration
Ignoring bootsnap-1.3.1 because its extensions are not built. Try: gem pristine bootsnap --version 1.3.1
Ignoring bootsnap-1.3.1 because its extensions are ...
0
votes
1answer
83 views
Using this web template in rails
Trying to get this free css/html/javascript template to work in rails. If you download it from here, you can see it is an index, a single css file and two javascripts.
I placed the home.html markup ...
0
votes
1answer
16 views
Script to Update field in rails
I have a csv file which containing parent and their children data.Parent has many children association. What I want is if the family_situation/gross_income or both are different for different children ...
1
vote
1answer
16 views
Error after deploying rails app with nginx server
I am trying to depoly my railsapp through nginx and passenger server. after finishing the installation steps, i typed the domain name but it results the following error.
404 found error
i followed ...
1
vote
3answers
33 views
Marking a course as complete automatically if all sub modules are marked as complete rails 5
Edit #1
Here is what I have now
<% if course.complete? %>
<%= link_to "Completed", course, class: "block text-lg w-full text-center text-white px-4 py-2 bg-green hover:bg-green-dark ...
1
vote
2answers
42 views
Rails How to set multiple polymorphic in controller?
Rails How to set multiple polymorphic in controller?
Some of codes as follows:
question.rb
has_many :comments, :as => :commentable, :dependent => :destroy
comment.rb
belongs_to :commentable,...
0
votes
0answers
25 views
Transfer the logic from the backend
I need to transfer the logic of displaying pages from the backend to the frontend, that is, I need to transfer this has_more_items, that is, that on the frontend it would be possible to receive data ...
0
votes
1answer
20 views
Get complete count from database rails 5
I'm working on a dashboard where I want to get a count based on a boolean record because students can click whether they have completed a module or not, here is the boolean in the database.
On the ...
-2
votes
0answers
9 views
how to get access token with login API in rails 5
I'm writing a Rails 5 app that will expose an API for a web app that's yet to be developed. Users will authenticate using an e-mail and password from the web app.
0
votes
0answers
9 views
What is the order of before_action in rails
I have two before_actions in base controller in order as follows :
before_action :method_1
before_action :method_2
But the execution is happening as method_2 is being called first and then method_1 ....
0
votes
1answer
20 views
How to add a new data to the index page with pagination without refreshing the page?
Post controller index is
<% if params[:topic_id].present? %>
<div class="new_post">
<%provide(:page_title,@topic.topic) %>
<h2><%= @topic.topic %></h2>
<%= ...
0
votes
0answers
5 views
Efficiently processing/sending large numbers of messages (email, sms, chat, etc…)
First, I have lists of subscribed users and some are required to receive certain email/sms communication as part of their usage of an app I'm working on. This is not about spamming mass users, but ...
0
votes
1answer
37 views
Controller's variables are modified when a model's name has a suffix in “che”
Based on this tutorial, I created a new rails project with the flag --api:
new rails project --api
As mentioned in the tutorial, I added in config/application.rb this line:
config.app_generators....
4
votes
1answer
1k views
Rails 5.2 with master.key - Heroku deployment
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 ...
0
votes
1answer
25 views
Cannot update boolean column with Rails 5.0.1 and MySQL
I have a model Diary, which has column is_draft (boolean, null: false).
I set it enum scope like is_draft: { draft: true, published: false } .
When I execute this in rails console,
Diary.last.update!...
0
votes
1answer
15 views
Getting Unpermitted parameter warning
I am using Rails 5.2.1 and ruby 2.5.0 for the development of my new project.
I need to permit user params which has the following structure
{
"user_id": 1
"name": "John",
"pets": [
...
1
vote
1answer
124 views
prepend module with ActiveSupport::Concern ? ruby 2+
Module Baz
def foo
super
:baz
end
end
Class A
prepend Baz
def foo
:bar
end
end
A.new.foo //works fine
now if I transform my module to Concern module, it's not...
...
1
vote
1answer
29 views
Restful management of Devise model records | Rails 5.2
I'm working on a project that involves two Devise models (User and Admin). What I'd like to do is allow for Admin members to be able to view and manage Users in a RESTful way (i.e: index, show, create,...
0
votes
1answer
86 views
increase items in shopping cart using rails and redis
I am having trouble increasing the quantity of items in the cart. It will only add one, then the it switches to the 'remove' button. Is there some way I can reconfigure this so I can add more than one ...
0
votes
0answers
14 views
How to pass :current_user in Graphql resolver
I have QueryType
Types::QueryType = GraphQL::ObjectType.define do
name 'Query'
field :allProjects, function: Resolvers::Projects
end
And Resolver like this
require 'search_object/plugin/...
1
vote
1answer
27 views
Import data from CSV into two tables in rails
I have a import CSV feature in my rails app. I have parents table and children table. Parent has many association with children. I am able to get the parent details from the CSV but I am not able to ...
1
vote
1answer
18 views
Dropdown not updating with updated data in Rails
I am facing the problem with select options in Rails. While changing the state, the city options should be appended but it's not working for me. Please help me, what did wrong in that
This what I did:...
0
votes
2answers
11 views
Rails nested form on show page
I am trying to add addresses to a company with nested forms on the company#show page. I am successful in adding the new address, but when the page reloads, the form area for the new address is ...
0
votes
2answers
28 views
Get Stripe charge information rails 5 create order
So I'm implementing Stripe and users are able to purchase successfully, however, I would like to get the charge information, last 4 card numbers, card type etc so I can generate receipts using https://...
0
votes
0answers
14 views
Rails 5 Forms Not Submitting
I have a Rails 5 app and am using the bootstrap-form gem. Everything was working fine until a few days ago. Now, whenever I try to create or edit a form, whether I hit submit or cancel, the completed ...
0
votes
1answer
20 views
ActionController::UnknownFormat rails 5 controller
Edit #1
View for orders/show, I haven't added the invoice yet, but the view should work with or without the link to the invoice, right?
<section class="pt-4 px-8 animated">
<section class=...
0
votes
1answer
21 views
Rails 5 each loop activestorage files displays files attributes
I updated Rails to 5.2 version with ActiveStorage
Everything works fine, but when I perform a loop through my model attached files in order to display them as bootstrap cards, I see my files ...
0
votes
1answer
20 views
config.assets.compile = false - makes heroku not display my images in production
So I'm trying to make my Rails app as fast as possible and I read here that if I turned config.assets.compile to false. When it was true and I pushed code through the terminal the script in the ...
0
votes
1answer
45 views
Unable to render (double) nested form
I have 3 models, Classses, ClassPrices & Bookings. ClassPrices belongs to Classses & Bookings belong to ClassPrices. I'm having trouble rendering the form for Bookings on the ClassPrices' page....