Expire cache fragment not working

I'm trying to cache a side_bar. Into it, there is two list of groups (1: favorite groups, 2: others_groups) My caching aproach: 1.caching the two lists of groups into my model User def cached_groups Rails.cache.fetch([self, "groups"]) {group...
more »

2017-11-17 17:11 (1) Answers

Scope associated element with join table

I'm trying to scope the main group of my user. This group is noted with a cat: which is 2. So I thought of doing this with a scope like class User < ApplicationRecord has_many :users_group, dependent: :destroy has_many :groups, through: :use...
more »

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

Carrierwave extension_white_list is not working

I am trying to upload a file using carrierwave gem in rails. I want to allow users to only upload files. So, I have used the extension_white_list method of uploader as shown below. But then also it allows users to upload images.I am allowing the user...
more »

2017-11-17 08:11 (0) Answers

send_file vs html5 download attribute

It looks like the HTML5 download attribute is supported on every browser now, and I was wondering if there are any advantages/disadvantages to using this instead of creating a link and using send_file in a controller with Rails. ...
more »

2017-11-16 05:11 (1) Answers

Return even if more associations than scope asks

I have Users and Languages tables, joined by LanguagesUsers. LanguagesUsers stores the language_id, user_id, and level. Users can have unlimited LanguagesUsers. I want to get all users who have any two languages. I have two scopes in my user model: ...
more »

2017-11-15 23:11 (1) Answers

NameError: Uninitialized constant Twitter

When I try to run any command that uses the Twitter API in the ruby console, I get the error NameError: uninitialized constant Twitter. I have named this twitterFeed.rb because I read that it should not be named twitter.rb. This file is placed in m...
more »

2017-11-15 23:11 (1) Answers

Confused about Ruby on Rails routes.rb syntax

Suppose I had the following code in my routes.rb file. get '/dashboard', to: 'dashboard#index', :as => 'dashboard' I know what's going on (a public url being mapped to a specific controller/view file which will process and return the request...
more »

2017-11-15 20:11 (3) Answers

Ruby : hydrate hash values from array

Let's say I have an ruby array like this : values = ['val_a', 'val_b',..., 'val_z'] # 26 values And an hash with keys hash = {a: nil, b: nil, ... , z: nil} # 26 keys I know that the array is sorted, and I know that keys of hash are sorted, and...
more »

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

Ruby - Generate QR Code with mini logo

I'm using rqrcode gem for generate a qr code, but now i'm need to generate qr codes with the company logo in the middle. I'm alredy read the documentacion fot the gem but can't fnd the way to do that. thanks ...
more »

2017-11-13 17:11 (0) Answers

How to connect mysql2 to Ruby on Rails?

I am trying to work on a RoR project, I have created the project called tester to check my db connection, command which I had used is 'rails new tester -d mysql' my gemfile has mysql2 gem included I have installed mysql and workbench, and my database...
more »

2017-11-13 13:11 (1) Answers

Implement directory system in rails

I want to implement directory system in my rails app. User will have some abilities to manipulate directory. Create new folders and delete them. User will be able to upload only validated format based files in selected folder. Folders can also cont...
more »

2017-11-13 08:11 (0) Answers

Stub authentication in request specs

I'm looking for the way to do this but in request specs. I need to log in and log out a double or instance_double to Devise instead of an actual ActiveModel/ActiveRecord. By using the code in the wiki page: module RequestSpecHelpers def sign_in...
more »

2017-11-12 01:11 (1) Answers

Rails: Change next_page class of will_paginate gem

Is possible to change the class name 'next_page' of will paginate gem? For example is easy to change .paginate class, but I don't know if is possibile with 'next_page' :class - CSS class name for the generated DIV (default: "pagination") :previous_l...
more »

2017-11-11 08:11 (1) Answers

Ruby on Rails Install Error

New to Ruby trying to install devkit to get Ruby on Rails ran into an error when installing Ruby on Rails. Using version 2.4.2 of Ruby and 2.7.2 of Gem. Error is failed to build gen native extension (see image for full console response) Cmd Line Er...
more »

2017-11-11 00:11 (0) Answers

Rails: Loop thru two different models

I have implemented a basic search and I'm looping thru the results like this: views/items/search.html.erb <% if @items.present? %> <% if @items %> <% @items.each do |item| %> <%= link_to item.title...
more »

2017-11-10 11:11 (1) Answers

Paperclip upload and showing the image not working

I installed paperclip -> 5.1 and latest ImageMagick on Windows 7(yeah..i know) running Ruby 2.3.3 and Rails 5.1.4. I installed file.exe as suggested by paperclip instructions and added 'C:\Program Files (x86)\GnuWin32\bin' to my PATH. When i upload...
more »

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