rails 5, remote: true form empty data

I am trying to migrate Rails 4.2 application to Rails 5.1. In rails 4.2 we heavily used JQuery. At the moment I am struggling to make the forms, with remote: true attribute work properly. As an example this is a simple form where user select the coun...
more »

2017-08-10 16:08 (1) Answers

Override the global index_errors option

I have configured application.rb with the following option to add an index to errors on nested models: config.active_record.index_nested_attribute_errors = true I have many models and it works great, but I want to change this behavior in a single ...
more »

2017-08-05 03:08 (1) Answers

Rails Social Links Model

I'd like to store user's social profile links: facebook, youtube, instagram, etc. Is there a gem that has this model already set up, or should I create my own? If I have to create my own I'd create a polymorphic model/migration and re-use the share...
more »

2017-08-03 19:08 (1) Answers

Ruby On Rails Users Ranking

I have app with gem acts_as_votable. Every post created by user has upvotes and downvotes. I am using Sqlite3 on test and Postgresql on development, production. posts_controller.rb class PostsController < ApplicationController def upvote @pos...
more »

2017-08-03 15:08 (3) Answers

Rails: Nested form for many-to-one relation

I have two models: Interview and Interviewee. There is a many to one relation between Interview and Interviewee. I want to be able to add a new Interviewee when creating a new Interview using /interviews/new route. If the Interviewee was already pr...
more »

2017-07-31 15:07 (1) Answers

Ruby on Rails 5, Country Flags

Just to begin with, I want to apologize for my inexpertise. I'm still in the process of learning RoR. I'm currently attempting to practice building a semi-advanced website, which is one big step, but I've made a lot of progress. I'm currently sitti...
more »

2017-07-30 23:07 (2) Answers

Couldn't find Resturant with 'id'=5

I am building this app and nested the reviews inside the restaurants. i have set all the permisions so only the users who are the owner of the review can delete their reviews. when i delete the review , the restaurant also gets deleted and i get this...
more »

2017-07-30 22:07 (1) Answers

Sidekiq not finding object in worker

When I create a new User in my app, I run an after_create method which then asynchronously triggers a Sidekiq worker. This worker ... def perform user_id @user = ::User.find user_id # ... end ... always returns the following error: Ac...
more »

2017-07-27 00:07 (1) Answers

Acts_as_follower display follows RoR

I am using a ruby gem called acts_as_follower My code: user.rb class User < ApplicationRecord acts_as_followable acts_as_follower end users_controller.rb def follow @user = User.find(params[:id]) current_user.follow(@user) red...
more »

2017-07-25 14:07 (1) Answers

Could not install Mobility gem on Rails plugin

I'm creating a Rails plugin which uses Mobility gem. I can see the installer listed when I do rails generate --help But then if I run rails generate mobility:install I get this totally weird error: Could not find generator 'mobility:insta...
more »

2017-07-21 17:07 (1) Answers

Join works in the rails console, but not the view

I'm working in Rails 5. I have two tables with a HABTM relationship: publications and authors. They're connected by a join table, authors_publications. I'm trying to get the view to list the names of the authors associated with each publication, an...
more »

2017-07-20 22:07 (1) Answers

Ruby search for match in large json

I have a pretty huge json file of short lines from a screenplay. I am trying to match keywords to keywords in the json file so I can pull out a line from the json. The json file structure is like this: [ "Yeah, well I wasn't looking for a long ter...
more »

2017-07-14 09:07 (2) Answers

Unable to start server in development environment

i am using rbenv. my rails version is 5.1.1. my ruby version is 2.4.1. When i run rails s command i got following one liner error. Segmentation fault (core dumped) i have tried to reinstall ruby, try to start server using bundle exec rails s, bund...
more »

2017-06-22 12:06 (0) Answers

Rails 5 Active Record Record Invalid Error

I have two Rails model namely Invoice and Invoice_details. An Invoice_details belongs to Invoice, and an Invoice has many Invoice_details. I'm not able to save Invoice_details via Invoice model using accepts_nested_attributes_for in Invoice. I get t...
more »

2017-06-17 15:06 (2) Answers

How to add conditions for json model association

Im trying to include an association but only ones based on its attribute's value Joo Model: def as_json(options = {}) super(include: [:foo, (:bar).where('bar.accepted = ?', true)]) end undefined method `where' for :bar:Symbol Doing super(i...
more »

2017-06-11 19:06 (1) Answers

Rails adding data to tables upon creation

I have two tables User (Devise) and Phones I would like for it when the user signs up threw registrations done with devise, the user_id and the type of phone is loaded into the Phones table But I am not sure how to do this. I have linked the User w...
more »

2017-06-01 09:06 (2) Answers

How to use MariaDB with Rails 5

I have read rails 5 supports MariaD but cant find any instruction on how to use it with rails 5. Do I still use the mysql2 gem? Do I need to use the libmariadbd-dev library. Are any other gems required? ...
more »

2017-06-01 03:06 (0) Answers

Rails engine extending views, not overriding

I am aware that I can override an applications view from within an engine by simply creating the same file within the engine and removing it from the application (eg: 'users/show.html.erb'). However, what I want is to be able to extend the applicat...
more »

2017-05-31 14:05 (1) Answers

Verify if user follow without a Exists SQL request

i'm trying to build a following action into my apps. To achieve that, I used the most common way, a join table (:followers) to link the users and the posts. But I'm encountering a little problem of efficience. Because for each of my posts, It's gen...
more »

2017-05-30 04:05 (1) Answers