Schedule an ActiveJob in Rails

I'm doing a weather API which will get, process and save data from another API. In order to get the daily updates (request URL info, get the JSON/XML data, construct my data and save it to my database) I think the most proper way is to use an ActiveJ...
more »

2017-04-19 23:04 (3) Answers

ActiveRecord multiple where date range

Is there a more ActiveRecord idiomatic way to find which records have a start_at or end_at within a certain date_range? (Basically, need to find the records that start or end in a given time frame). Here's what I'm currently doing: Project.where('(s...
more »

2017-04-19 16:04 (2) Answers

Use Redis as primary database in Rails app

Hello I am newbie to Redis. I am trying to use Redis as my primary database instead of sqlite as provided by default with Rails. I tried enough googling but could not find relevant stuff. How to achieve this? Or if iam wrong whether can we use Redis ...
more »

2017-04-19 07:04 (1) Answers

My rails controller didn't work

My rails application is used acts-as-taggable-on. I would like to add function which articles can be searched by tags. In my articles_controller.rb def index @articles = params[:tag].present? ? Article.tagged_with(params[:tag]) : Article.all ...
more »

2017-04-19 07:04 (1) Answers

How to save a variable in an rspec expect?

I have something along the following lines in one of my spec files: expect(my_instance).to receive(:my_function).with(arg: instance_of(String)) I want to be able to capture the actual value of arg in a variable I can use in the spec. Is there a wa...
more »

2017-04-18 18:04 (1) Answers

Globalid and pg not existing when in gemfile

I am trying to rails server from a cloned repo, I have updated ruby, and rails, followed the rvm process, updated all my gem files, and when I go to serve I receive the message Could not find globalid-0.3.7 in any of the sources Run bundle inst...
more »

2017-04-18 01:04 (2) Answers

How to use the Geared Pagination gem

How do I use Geared Pagination? This is /app/controllers/links_conroller.rb: class LinksController < ApplicationController before_action :set_link, only: [:show, :edit, :update, :destroy, :visit] before_action :authenticate_user!, except: [...
more »

2017-04-17 19:04 (0) Answers

How to add image upload system in Active admin?

I tried a lot but couldn't get an idea. I am using windows 32 bit system and mysql as database. I tried https://spin.atomicobject.com/2016/07/23/file-upload-active-admin-paperclip/ this but it didn't save the image and its attributes on database. Ple...
more »

2017-04-17 03:04 (0) Answers

pass params into rails path helper

I'm trying to pass params into my rails path helper but my current attempt is not working. Here is what I'm doing now: <%= link_to "Pause Assignment", pause_account_complete_assignment_index_path(@assignment.current_timekeeper) %> Controller...
more »

2017-04-16 18:04 (1) Answers

undefined method error with weird class name

If everything is an object/class in ruby, why can't ruby tell me the name of a class/object that causes an error. undefined method `changed_servings?' for #<#<Class:0x00000009a4fa70>:0x00000009814558>): I want to know what <Class:0x...
more »

2017-04-15 03:04 (2) Answers

How to update Ruby on Rails in Ubuntu?

Now I have installed 5.0.1 version of Ruby on Rails. I want to update it up to latest version 5.1.0. Firstly I tried to update gem system file. After I changed line in gem on gem 'rails', '~> 5.1.0' Then to run command gem install, but it did ...
more »

2017-04-14 22:04 (1) Answers

How to add primary key to Rails?

I'm trying to make an e-commerce website type thing using Rails. So I've made my models for it. My problem is how to make a particular element a primary key? create_table "bookmarks", :primary_key => bk_id force: :cascade do |t| t.string "bk...
more »

2017-04-14 09:04 (3) Answers