Questions tagged [ruby-on-rails]

Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its "convention over configuration" approach to application development.

Filter by
Sorted by
Tagged with
0
votes
0answers
4 views

Rails 4 downloaded excel file using send_data method is giving format error

I am downloading data in excel format in my Rails 4 app using send_data method as mentioned below. send_data collection.to_csv(col_sep: "\t"), type: 'application/vnd.openxmlformats-...
0
votes
0answers
10 views

How to randomise a .where

def books_made_by_followed_authors Book.joins(:languages) .where(author: current_user.followed_books.select(:author)) .where_subquery('languages.id IN (?)', current_user....
0
votes
2answers
14 views

Will be valid an activerecord intance passed as parameter to mailer that will send later?

I'm passing as parameter a instance of ActiveRecord to a Mailer through: SomeMailer.with(my_instance: someActiveRecordInstance).welcome_mail.send_later And then, later when the email will send I do ...
0
votes
0answers
16 views

Rails gem strong_migrations vs zero_downtime_migrations

I was looking at the READMEs for https://github.com/LendingHome/zero_downtime_migrations and https://github.com/ankane/strong_migrations It seems like strong_migrations offers more functionality with ...
0
votes
1answer
11 views

how to install inputmask on rails 6 with webpacker using jquery dependency

I'm trying to install inputmask on Rails 6 via webpacker. Currently getting following error: Uncaught TypeError: $el.inputmask is not a function current setup, compiles with not issues. app/...
0
votes
1answer
17 views

Rails API - React: Site ID returns null on POST

My app has a Rails API back end and React front end. The ERD only has three params: a User has_many :sites, a Site belongs_to :user and has_many :pages, and a Page belongs_to :site. All the CRUD ...
0
votes
0answers
11 views

Can not change session variable value after login in Rails 4

Got a very weird problem in a Rails 4 application that session variables can be correctly set before sign in but can not after sign in It is an old app with Rails 4.2.11 and Ruby 2.2.10, Devise 3.5.6 ...
-1
votes
1answer
22 views

How to add multiple categories in Rails?

I use Ruby on Rails 5.2.3 and Mongoid I try to add multiple categories. category.rb class Category include Mongoid::Document has_many :tickets belongs_to :user end ticket.rb class Ticket ...
2
votes
2answers
27 views

Ruby on Rails Flash Notice Not working properly

Flash notice is not working. I am using rails 5.1. My code is like this: def message redirect_to users_path, notice: "Message" end <% if flash.present? %> <% flash.each do |k, v| %> ...
0
votes
0answers
29 views

Partial not found when attempting to render it from an Ajax call in Rails app

Rails 5.2.3 I have the following Ajax call: function renderSalesDayDashboard(date_target) { $.ajax({ type: "POST", url: "sales_day_dashboard", data: JSON.stringify({ "date_target"...
0
votes
2answers
17 views

Edit with a belongs_to relationship

Issue I'm encountering a problem when editing a form with a belongs_to relationship (extra_guest belongs_to age_table). I am able to create a new extra_guest and assign it to an age_table, but I ...
0
votes
1answer
24 views

Manager -> Employee association one level in rails

I want to create manager->employee association. Manager have many employees Employee belongs to only one manager Manager does not have another manager How to implement this design ? I created ...
0
votes
0answers
30 views

Unknown primary key for table in model

I am getting unknown primary key for table, I am not able to judge why this is coming My Table has primary key CustomerNote # == Schema Information # # Table name: customer_notes # # id ...
0
votes
1answer
13 views

If new active record has attributes, then create a has_many association

I have a DoSomething model. This model allows super users to tell other users to do something at a certain time. I want to allow super users to a send either or: a reminder to the other users to do ...
0
votes
0answers
21 views

Sorting in Rails/Grape

I want to add sorting for pdf_path in my admin panel in Rails with Grape. I thought all I should do is to add one line to the :sort hash but it turns out I've got an error: ActiveRecord::...
0
votes
0answers
9 views

Rails, efficient and clean way to parse html to replace img with responsive picture tag

I need to upgrade my CMS to handle responsive image. The problem is that CKEditor, Redactor, Froala and main wysiwig editor cannot handle responsive images, so I have to find a workaround: in my ...
0
votes
1answer
10 views

Devise why sign_in_count in BLACKLIST_SERIALIZATION

I would like to know why sign_in_count and current_sign_in_at of :trackable option are blacklisted by devise, I understand that encrypted_password is blacklisted but sign_in_count... Thanks !
-2
votes
1answer
40 views

Ruby installation issues

I am trying to install the ruby version 2.3.5 in my mac OS environment which is Mojave. I am getting the following issues. Appreciate If anyone can help me to sort out the issue ? ERROR: Ruby install ...
0
votes
1answer
15 views

Submit simple form remotely on the basis of a click event

I am trying to create a todo app in which the checkbox is created using the simple form and this needs to be submitted remotely when the checkbox is clicked. I am using the onchange() function but the ...
0
votes
0answers
8 views

Authorization jwt_sessions Rails

I am working with authorization with Rails(gem jwt_sessions). I have login controller & refresh controller. I set up cookies(jwt_access, refresh_access, csrf). In most cases server responds with ...
0
votes
0answers
12 views

Wrong I18n locale is loaded randomly

Sometimes instead of expected Japanese language config, the English config is being loaded, which actually doesn't exist and isn't set anywhere neither as a default_locale nor as a fallback one. ...
0
votes
0answers
11 views

i want a dropdown in rails simple form in which i can add author as subscript with option and want to get both author and value of the selected option

i want something like this.....Checkout the image how i can do that inside rails simple form i have done something but it's not satisfactory as well as its not working also.... Here is my Code: = ...
0
votes
0answers
19 views

Belongs_to relationship in edit

I'm encountering a problem when editing a form with a belongs_to relationship (extra_guest belongs_to age_table). I am able to create a new extra_guest and assign it to an age_table, but I cannot ...
0
votes
0answers
12 views

Rails: Failed to authenticate with Slack

Thank you so much to help me in advance. I'm working on an application where people authenticate with Slack and it send a notification to their workspace at the same time the contents generated ...
0
votes
0answers
19 views

Is instance variables in rails are reset every page refreshed?

I would like to know if instance variable are reset everytime I refresh the page ? And is it possible to not reset it ? Thanks !
0
votes
1answer
16 views

Use a sql file to populate data in ruby

I have a sql file and i want to use it to populate the psql in RoR. the psql ___ < ______.sql is not working ? Can you please guide me on how to use this sql file and use it
0
votes
0answers
21 views

Scheduling Auctions

I am working on an auctions site and I want to schedule auction so users can set the date and time they want their auction to start and end. I added Published_at, end_time and draft which is default ...
0
votes
0answers
22 views

Devise routing error ActionController::RoutingError (No route matches [PUT] “/”):

After make a PUT api call in /dashboard_users/update, devise return me a error message: ActionController::RoutingError (No route matches [PUT] "/") Here is the full error: Started PUT "/...
0
votes
0answers
21 views

Rails i18n gem excludes attribute name from error messages for non-English locale

The Rails app I am working on uses the Japanese locale. In order to use default translations for error messages, I installed the rails-i18n gem, but I am having trouble getting it to display full ...
0
votes
0answers
27 views

JSON to HTML Form. Ruby on rails

Problem: I am trying to convert a JSON object into a html form or generate a form out of a JSON object. I am using Ruby On Rails. ***I do not want to use a library for this. I want a custom solution ...
0
votes
1answer
21 views

How to add multiple database strings in page title

I'm trying to create a dynamic page SEO title which differs from the @project.title To expand on the project title, in the page title I want to have project name, project category in project city. &...
1
vote
0answers
50 views

Rails - Saving in a table and update/creating in another one

I am creating a small app to manage my own online portfolio but I can't solve an issue with update. The main table of my database is works, then there's the tables authors and clients where I set the ...
0
votes
1answer
26 views

Single Table Inheritance + Relationships

I'm creating a rails 5 application (a sort of job finder that connects recruiters with applicants). There is a part of my model configuration : class User < ActiveRecord::Base ...
0
votes
1answer
20 views

Mock carrierwave using rspec

I need to run my specs without generating the upload file. I'm already using the clean up strategy after run specs but I would like to use a mock in order to not generate files inside the project. I'...
0
votes
1answer
16 views

How to create a rails service for controllers with access to cookies and session

I want to create a service to DRY my controllers, and make them more readable (and avoid the use of concerns), but this is not a common service, because it'll be able to get and set cookies and ...
0
votes
1answer
19 views

Manually changing a migration

It's my first time using Rails, and I would like to know if it's ok to manually change a migration file that was created with the CLI. I used the CLI to create a <date>_create_posts.rb file, but ...
0
votes
1answer
35 views

Rails/Heroku test a future time

I have alot of features that rely on expiration dates and future times, we use timecop in our rspec/unit tests but I was wondering if anyone had any clever solutions for how a product/QA person could ...
2
votes
1answer
28 views

Find values that each subarray of an array contains

I've got an Array of arrays. There can be two or more subarrays: array = [ ["66892885", "66891801", "66924833", "66892255"], ["65167829", "65167828", "66924833"], ["66924833", "66891801"] ] I ...
0
votes
0answers
13 views

How to implement Image_processing backend pipeline?

If I try one of these methods on view it works: <%= image_tag upload.variant(resize_to_limit: [75, 75]) %> <%= image_tag upload.variant(resize_to_fill: [300, 200]) %> but when I ...
1
vote
1answer
27 views

has_one association not adding methods to belongs_to class

I have two tables User and UserToken. User has_one: token and UserToken belongs_to :user. I was under the impression this would add UserToken#User method to the UserToken class. However, I am getting: ...
0
votes
1answer
24 views

#<TypeError: no implicit conversion of nil into String> for jwt encoding environment

I am receiving a TypeError: no implicit conversion of nil into String for my encode_token method using a "jwt_secret" environment. I have made sure that my Here is my ApplicationController. The ...
0
votes
0answers
38 views

how to import and execute database connection in a script

I am writing many scripts to run housekeeping tasks on our system. At the top of each script, I establish a connection to the database using ActiveRecord::Base.connection. I would like to keep this ...
0
votes
2answers
71 views

update params hash in rails

I need a way to modify the params hash. I tried a couple of things but none of it actually worked. Unpermitted parameters: :players, :leaders Params {"utf8"=>"✓", "authenticity_token"=>"asa"...
0
votes
0answers
18 views

Invalid Byte Sequence in UTF-8 from Excel file

(Ruby 2.5) I have a method that reads and parses a csv file that's being uploaded via Alchemy CMS def process_csv(csv_file, current_user_id, original_filename) csv_string = csv_file.read.encode!("...
-3
votes
2answers
28 views

Where to put $(Document).ready(function(){});

I have read that for jQuery to work I have to have this code: $(Document).ready(function(){ //some code )}; But I'm unsure which file is compiled first into application.js, so where do I have to ...
0
votes
0answers
34 views

Ruby: Parsing time from a string

I'm trying to pass an array of times kept as strings (["08:00:00", "18:00:00"]) and return them in a more readable manner via a helper method. However, I keep receiving an Arguement error in the ...
0
votes
1answer
25 views

How to use Rails Web App as ruby script input and output

I'm new to rails and I'm working on this project: I have done a ruby script which needs an input and that prints some outputs. Basically it takes the first n decimal digits of PI and then it ...
0
votes
1answer
25 views

How does “[attribute]_changed?” work with CarrierWave mount_uploader :[attribute]?

I have got CarrierWave uploader in my model. before_validation :parse_template_file, if: :template_file_changed? mount_uploader :template_file My code above doesn't work throwing NoMethodError ...
0
votes
1answer
18 views

Unable to create user object in rails backend using JWT authentication

I am trying to create User objects in a rails PostgreSQL database using JWT authentication. When I fire the create user method from my React frontend the user is not created in the backend and I ...
0
votes
0answers
9 views

Why does bundler fail to resolve dependency in gems where there is no actual conflict?

Here's an example bundler output that I am trying to resolve: Bundler could not find compatible versions for gem "actionmailer": In Gemfile: knife_core (~> 5.0) was resolved to 5.1.0, which ...