Newest 'ruby-on-rails' Questions

Q&A for professional and enthusiast programmers

unable to add new poll option in ruby on rails

i have been working on this web app and now i got stuck with this i tried my best but unable to understand what is wrong here please help when i click on add new poll i get error message ** ...

Creating IOS purchase on Ruby on Rails server

If somebody knows the way that i can create in-app purchases for IOS from my admin panel (written on Ruby with ROR) I would really appreciate your help. I know Google provides this functionality to ...

Actual expectations of a RSpec routing spec is always different from what I specify as expections

I have this spec: RSpec.describe 'Routing (i18n)' do describe 'Features' do it 'has its routes translated' do expect(get: '/de/features/automatischer-notruf-ecall') .to route_to(...

How do I design controllers and views for a rails attendance model?

I'm new to programming and chose rails to develop my prototype. I am designing an attendance tracker for an app I am developing. Here is my progress so far. A Users Model (Gym) class User < ...

ruby on rails read decoded xml string from post

this is on rails 3/4 (two different test environments). i have a client that base64 encodes XML in a POST. I can decode the string, which looks like well formed XML. How do i turn that into XML ...

rails routes link_to specific controller action

For a simple quiz app I'm trying to connect a couple of static pages, but since I'm new to Ruby on Rails I'm having trouble with how to correctly define my routes. I have a static page pages/...

filter child records, but don't filter BY them

Does that make sense? Well, here we go: I have a parent class, Foo with has_many bars as a relationship on the model. class Foo has_many :bars scope :available_to_user, -> (user_id) { active....

Getting redirected after updating user (Session destroyed)

I use devise and cancan. (i'm a RoR newbie) So, users can be created/updated/deleted/ only by admin user, default users can only log in(by now). (user with role :admin in role table) Everything ...

heroku pg:reset DATABASE is not a heroku command?

I'm trying to reset a postgresql DB on my rails 5 app hosted on Heroku. This is not my first time so I type with full assurance the following command : heroku pg:reset DATABASE And then it's the ...

How do fat arrows work in Rails routing methods?

Often times in the routing section of the Rails docs I see the fat arrow => used in the get method. The only time I see the fat arrow token used in Ruby is when writing key/value pairs in a hash. ...

Elasticsearch doesn't find all records

I'm using rails 5.0.0.1, elasticsearch-model, elasticsearch-rails and the search for some records works correctly for whole world and for partial but for other records not works totally. ES version 2....

Rails | Handling Users / Admin / Call Center Panel

I have a rails app and within I have User model. I added admin:boolean column to user table and :default => false. Now I would like to create a call center panel on the system to be able to ...

Performance about Select2 library when using large data sets

My question is about performance of Select2 extension when using large data sets. I've more than 9000 options in select.I don't want to use ajax calls to fetch them. At this moment it's like takes 2-3 ...

“Google is not defined” error on ruby on rails

I have a html and js file (maps_scripts.js) in which I have defined all the google maps function related to the mentioned html page. These two are working really fine. I've been assigned to include ...

wrong location in respond_with multiple object

I have to pass 2 objects to show so I tried to put this respond_with(@ticketnfr, @ticket) but it goes to ticket controller view, when I tried with only one object respond_with(@...

ActiveRecord 5 always execute subqueries separate from main query

Could please somebody explain me how to fix following behavior? (ActiveRecord 5.0.1): subquery = User.where(id: 1); nil => nil 2.3.3 :002 > User.where(id: subquery.select(:id)) D, [2017-04-...

How do I deploy multiple branches of a repository simultaneously using heroku?

I have a repository on my machine. I push it to bitbucket. Now, on my local machine I make a branch=>make changes in the branch=>git commit -a -m "message"=>git push -u origin =>heroku create => git ...

How to convert a string in to an array in ruby without using split method

I want to convert the string into an array without using any split method. "Country ,blue,of, origin" I want a desired output like this. [Country ,blue,of, origin]

Rails: How do I force a new asset digest on ALL assets?

Running a rails 4.2 app with sprockets and using asset digests. When running rake assets:precompile it creates all my assets with digests. I need however to bump all asset digests to help me debug ...

Upload Image to Rails API using React-rails

I build an apps that use React-rails as front-end (View) and Ruby on Rails as back-end to handle API. Both are on different server & database. I know that i need to use gem like Carrierwave, ...

Rails - 5: How do I pass an array (has_many association) to the controller action

I have a model event and another model event_rule class Event < ApplicationRecord has_many :event_rules end class EventRule < ApplicationRecord belongs_to :event end I have written an ...

Google DFP Ads with Rails Turbolinks 5

Ads are not populated/loaded on page refresh. It's working nicely when I click and browse through site. I can't figure out what is wrong with this code. Here is my code so far. class App.DFP ...

How to add postgresql library pgroonga when make docker compose?

How to add postgresql library pgroonga when make docker compose? I want to add dockerization to my current Rails project. It's using PosrgreSQL database and pgroonga library. The docker official ...

grape - table read as a constant

I'm using rails 5 and grape for api, I'm trying to create grape endpoint for the table application. module PROJ::API::V2 class Applications < ::Grape::API get '/' do authorize! :...

bootstrap3-datetimepicker-rails Display Issues

I'm using this gem to try and get a datetime picker for one of my fields: https://github.com/TrevorS/bootstrap3-datetimepicker-rails In particular from the example documentation (http://eonasdan....

Heroku ACM problems – stuck at “DNS verified”, sites down

Our Heroku application initially had $20/m paid SSL add on –– we still have this installed At some point we switched to the letsencrypt-rails-heroku gem –– this appeared to be working fine up until ...

Synthax differences between method calls and variable calls in embedded ruby scripts?

This might be a noob question but here it goes:I'm trying to parse embbeded ruby code and I need some help in understanding the synthax for methodcalls and variable accesing in embedded ruby scripts. ...

Github Api call from rails

I want to give a call to github API i.e GET /users/:username/repos.Using HTTParty gem in rails if I do def details response = HTTParty.get('https://api.github.com/users/john/repos') end I get the ...

Make files in google drive shareable

I have created a Rails application which allows user to upload a video file to Google Drive. The uploaded video is to be shared on the Rails View. I have done it through session.upload_from_file(...

Ruby-mysql troubles - Getting error while trying to use mysql module for Ruby

I'm using Ruby v2.0 AND i'm using the Ruby-mysql v2.9.14 connector from here: https://rubygems.org/gems/ruby-mysql I'm getting a number of errors while running this code: require 'mysql' begin ...

How to define routes for a polymorphic model under namespaced & non-namespaced parents?

How to configure routes for a polymorphic model, so that the form can correctly adapt to namespaced and non-namespaced parents. i.e., so that a partial containing <%= form_for [@parent,@comment] ...

rake task for webpush notification

I have in challenge_reminder.rake task challenge_reminder: :environment do Challenge.unaccomplished.all.each do |challenge| if challenge.remind.include? Date::ABBR_DAYNAMES[Date.current.wday]....

React JS switch active parent from child's custom function

I have the folowing react component's structure: Statements -> Statement Statements have state activeIndex: 0 by default to switch active Statement, switching by clicking works fine Statement have ...

How can I do something atfer validates fail from particular field in rails?

I have a situation like that, I wanna check a field before save if it's a correct URL then save it, if not then change it to a correct way, my question is the validates function(regexp) is similar to ...

pg gem install fails

Centos 6.9 (similar to question: Can't find the PostgreSQL client library (libpq) but that one is on MacOS not Centos, so those solutions did not work ruby 2.1.8 (tried 2.2) rails 4.2.6 (tried 5....

Before save call back ruby on rails

I am doing a currently a project and I am using a devise.. In my sign up(using the devise) I have field named mobile number, when I click the sign up/submit button it will be save into my table but ...

feeding search params through a redirect_to in Rails

I'm trying to pull a search parameter from my view to another view after I do a redirect_to in my Rails controller. I can get it working by forcing in the text to my parameter in the controller but I ...

Omniauth-Identity with Omniauth-Facebook, sometimes skips to create user in User model

I'm trying to use user authentication with omniauth-identity and omniauth-facebook, I have two models User and Identity and everything working fine, sign up with facebook, sign in, signout, also with ...

Passing default params to rails form_for

I have a simple form like: = form_tag history_path(params), :method => :get do = radio_button_tag :history_id, @history.id, true History %br = submit_tag "Get History", class: "btn ...

Avoid creating database records to speedup rspec tests

I have the following test in my spec/controllers/my_controller.rb let(:user) { User.create!(first_name: 'name', email: 'mail@example.com', password:...

Spree - undefined local variable or method `meta_data_tags' error

I have this line in my layouts/application.html.erb file <%== meta_data_tags unless content_for? :head %> and I am getting undefined local variable or method `meta_data_tags' error my ...

getting No route matches [GET] “/show_house_search.38” in rails

I defined a new method in my controller to show customized show page for my houses after one click on search results. houses_controller.rb def show_house_search @house = House.find(params[:id]) ...

Dokku DigitalOcean Deploy (Cannot access Rails Sample App)

Trying to deploy an app to DigitalOcean using Dokku Followed the instructions on: https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-dokku-application then: http://dokku....

Scope/query based on a specific instance of an has_many associations

Let's say I have a Person class with many transaction_records. How do I retrieve all the Person which have their last transaction_record(based on created_at) having a created_at attribute older than ...

Windows can't find python while installing mini_racer

I'm trying to setup Rails on native Windows 10 (since WSL is 10x slower). Installing mini_racer gem fails with the pasted output, it says it cannot find python 2, although I have it installed and in ...

best_in_place reverts back to original amount until page refresh

In using the best_in_place gem I'm updating table data without a page refresh. The data gets updated briefly, and then reverts back to the original amount until I refresh the page and then it shows ...

How can I use will_paginate when query has group by statment?

I have this query for retrive information from database: select("DISTINCT(#{table_name}.user_id), #{table_name}.exam_id, #{table_name}.passed, #{table_name}.percent_successful, t1.attempts, ...

Create new entry from nested forms in Rails

I followed the Railscast #196 for nested forms and I am successfully able to edit, add and delete from nested forms as long as the record is already created. Now I am trying to use nested forms to ...

capistrano + sidekiq / unable to pick environments variables

So the problem is not that uncommon as so far I could've gathered loads of issues about it, but still, without being able to solve this on my own I had the following task : namespace :sidekiq do ...

Rails: create form modal

I'm trying to create a bootstrap modal with form to add a new entry to the index. could you give a hint or show how to best achieve this. My need is that: The button 'add' in the index page on click,...
Translating... 0%