Ruby on Rails search function solutions

I'm new to Ruby on Rails, so I have serveral questions to my search function. Search View: <p> <%= form_tag students_path, :method => 'get' do %> <p> Advanced_search: <%= check_box_tag "advanced_search", value = "1" %> &l...
more »

2017-04-06 21:04 (1) Answers

activerecord model with 2 parent levels

A user can have many questions. Many users can participate on a question and provide multiple answers to the same question. Relation between users and questions seems to be working fine. Problem is with answers. model/user.rb has_and_belongs_to_m...
more »

2017-03-31 21:03 (1) Answers

rails dispatch event?

First off, I am totally new with gems and engines (eh. ruby); I am writing a handy engine which is going to filter requests based on the rules the user(developer) defines, currently my approach is the following: class ApplicationController < Acti...
more »

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

How to stub current_user in Rails 5?

How do I stub current_user in Rails 5? I expected this: @controller.stub :current_user, mock_user do end to work, but there is no @controller in ActionDispatch::IntegrationTest? I use sorcery gem for authentication. ...
more »

2017-03-25 23:03 (1) Answers

Rails .where() query not working

Thanks a lot for your help. I have a locations and ads table. Location has_many :ads I perform the following query on Location Model. @locations = Location.joins(:ads).where(@location_params.require(:location).permit(:id)).includes(:ads) Then I wa...
more »

2017-03-13 10:03 (1) Answers

Rails 5 Server Issues (Windows 10)

Newbie to Ruby on Rails here, I just did a fresh install of Ruby & Rails on Windows 10 (Bash on Ubuntu shell). I seems to having issues on starting the Rails server. Already checked the other threads on the issue, but everyone else is using OSX. ...
more »

2017-03-10 06:03 (1) Answers

Sidetiq not working post Rails 5.0 upgrade

I am in process of migrating a rails app to Rails 5 / ruby 2.4 from Rails 4.2 / ruby 2.2.2. Most of the "issues" that I've encountered have been straightforward to address, but this one has me a bit stumped. I have a number of recurring jobs that I...
more »

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

How to group and sum all currencies

I hope the title is correct. I need to sum all currencies ie all of $, £ etc, but not to combine all into one sum. Basically if I have 2x $4 and 3x £10, that will be $8 and £30 I have an Income model with attributes :currency (string) and :amoun...
more »

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

can't use polymer gem in rails 5.02

I'm new to using rails and polymer, and I followed the instruction in the, but $rails g polymer:install command did not work. Here is the output from running $rails g polymer:install /Users/someuser/.rvm/gems/ruby-2.3.3/gems/bundler-1.14...
more »

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

How to get started with the gmail-ruby-api gem

I working with Gmail using the Gmail for Ruby gem, but can't figure out how to get started with it. The documentation say: I could do something like: require "gmail" Gmail.client_id = "...Your app client id..." Gmail.client_secret = "…app secret...
more »

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

Rails Localhost not working

So when I run "rails server" and try to open any project, i get this error when trying to open localhost:3000 : Error But this is what my terminal says: The thing is I thought it was because me pushing to git heroku was causing it to fail so anot...
more »

2017-02-27 20:02 (1) Answers

Use a namespace only as param

At the moment my routes are looking like this: search_index GET /search(.:format) search#index But I want to get routes like these: search_index GET /topic1/search(.:format) search#index search_index GET /topic2/search(.:format) s...
more »

2017-02-21 08:02 (1) Answers

Can't dup NilClass (TypeError)

I am trying to run my cucumber tests, but I get this error. I am wondering what is the source of the problem and how I can go about debugging it? can't dup NilClass (TypeError) /Users/jeffreyyong/.rbenv/versions/2.4.0-preview1/lib/ruby/gems...
more »

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