Newest 'ruby-on-rails' Questions

Q&A for professional and enthusiast programmers

Rails 5 ArgumentError (wrong number of arguments (1 for 0)

In my Rails 5 app, I'm using the Public_Activity gem and I'm trying to record an activity, but running into an error: ArgumentError (wrong number of arguments (1 for 0). I tried to record the ...

Do I need a wysiwyg?

I have an app that records projects in a model. The project description, a text field, needs to be presented in s readable format and could be a couple of paragraphs. Do I need a wysiwyg for that? ...

restore untacked file from .git/info/exclude

First I want to ignore the config/environments/development.rb, so i added it into the .git/info/exclude, and it worked. When I do want to restore it, and add it in my untacked files. I delete that ...

Testing devise user login but getting 401 unauthorized response

I'm using devise_auth_token gem in rails-api application where i'm trying to test if a user is logged_in then user is authorized to render through index action in welcome_controller. ...

Javascript function is only triggered on page refresh

This happens in a Rails 5 application with Ruby 2.3.1. When a dropdown list is changed, I want to collect more information via an ajax request to display below the dropdown list. This functionality ...

Rails Optimize tree structure code by eager-loading

I want to show a drop down with tree structure.By using this SO solution given by @manoj, the code for category_options_array displays the tree wonderfully in the select form control for a model with ...

How to run first method on nil?

Sorry, but I simply can't get my head around this: class Customer < ActiveRecord::Base def self.first_one order(:created_at).first.id end end The function above returns the first ...

RAILS : How can I make a MarkDown friendly editor in my personal blog? [on hold]

I am working on building my first blog. With the help of Ruby on Rails form helpers, I managed to have a very primitive text editor to write blogs. But I would like to have a nicer one which supports ...

No route matches {:action=>“partner_update”, :controller=>“users”}

i'm new in rails so i tried to do this to add a role, making a form to update and if the user update succsessfully add the role. note: i'm using devise and rolify with cancancan routes get 'users/...

How to sign users in and out for testing with Rspec + Devise + FactoryGirl

I'm new to Rspec, but I've managed to put together a working (at least in my tests so far) setup that lets me test various behavior in logged in/logged out states using FactoryGirl + Devise and Warden ...

RSpec: Multiple asserts for a controller spec

Let me explain the issue... I was testing a Rails controller with RSpec and I have one scenario with about 8 asserts.. I don't like to have an "it" with that amount of asserts so what I did was this:...

Pass an instance object as the parameter into redirect_to method

I am learning Ruby on Rails and I am not sure what my understanding is correct. I just define a method in controller: def create page_params = params.require(:page).permit(:title, :body, :slug) @...

elasticsearch-ruby dsl nested bool queries

I'm using elasticsearch 2.4 version and elasticsearch-dsl gem. What I want to do is to fetch all data from ES index which are from Paris plus all data which are not from Paris close to paris like 10-...

Where Like Active Record query only working when params is a one letter string

So I'm trying to do a basic search form with Rails that should retrieve any records which have a title similar to the query. In my controller I'm using the following code to perform the search def ...

Migrate column data into new join table in Rails?

I need to migrate a table column's data to a Join Table which will hold the relationship between the old rows and new indexes. Is there a standard way to do this in Rails?

Broken Image when uploading images to Amazon S3 with Heroku ?

I am trying to use amazon s3 on my web app but the images are not showing on Heroku. I have setup the correct environmental variables and the AWS region but after the image uploads i get a broken ...

Removing Rails 4.2 Deprecations from migration file

I am going migrate my application to Rails 5. So I am now doing the process of removing all Rails 4.2 deprecation. I get the following deprecation warning DEPRECATION WARNING: `#timestamps` was ...

Ruby on Rails first_or_create nested model

Place Model: class Place < ApplicationRecord has_many :post_places, dependent: :destroy has_many :posts, through: :post_places end Post Model: class Post < ApplicationRecord has_many :...

Reading a cookie only 1 time at the browser opening

I am developing an app that shows some results depending on the "city" that the user is browsing my app. I'll only use this location info for displaying some results, nothing more. I read this and ...

Unable to autoload constant ApplicationController(all controllers)

I just started receiving this error for all controller. Not sure what happened, because I was working on UI so CSS, ERB files and then I reload the page and start getting this error. Thanks for any ...

Permit multidimensional params

I receive this params: <ActionController::Parameters {"page_hierarchy"=> [<ActionController::Parameters {"id"=>"6", "children"=>[ {"id"=>...

Passing arguments to vbs script while calling it from RAKE

require 'open3' stdin, stdout, stderr = Open3.popen3('cscript pdxGen.vbs mmr_nisa') puts stdout.readlines This is my code which runs the pdxGen.vbs script. The script is running without any errors. ...

Getting wrong message with DataTable “Showing 151 to 144 of 144 records”

When i change the show count value, while on the last page, results in a blank page being added to the page display. & If the last page is selected "No records were found" is displayed and showing ...

Dockerfile automatically run passenger start with Rails

I've built a Rails image with docker, but now I don't know how to use Dockerfile to set the passenger. My Dockerfile now is FROM username/my_app:latest WORKDIR /my_app # Expose port 3000 to the ...

Social Media Profile Gem for Ruby on Rails?

I am trying to find a gem that will allow me to add social media(Facebook, Twitter, LinkedIn, and Google+) to client profiles of my app. Like this images: 1 and 2. How can i do? Thanks for any help!

Ruby version error on deployment with capistrano

I am getting ' Your Ruby version is 2.3.3, but your Gemfile specified 2.0.0' when I am trying to deploy with Capistrano. my gemfile specifying 2.3.3 ruby "2.3.3" 00:27 bundler:install 01 /usr/...

How work with multiple select with Devise and Rails?

I have a city model class City < ActiveRecord::Base belongs_to :country end And I also use standart Devise gem for user registration and login. Now I want each user to have a multiple countries ...

How to disable other validations in case more important validation error is caught

I want a (numerical) model attribute foo to be validated as (1) present, and (2) be greater than or equal to 0. Since (1) is a prerequisite to (2), in case no value is given for parameter foo, I ...

How to update ruby from 2.0.0 to 2.2.2 in ubuntu 16.04?

I am using ubuntu 16.04, ruby 2.0.0, rails 4.0.13 and mongoDB 3.4.2. I want to update ruby to 2.2.2 but I am getting error : Error running 'requirements_debian_update_system ruby-2.2.6', showing last ...

Check if correct number of links appear with Rspec

I'm re-writing tests from Test Unit into Rspec/capybara and I'm just trying to figure out the correct syntax. I want to hit the root_path and check that there is exactly one links to '/' (in the ...

Rails: Partial Rendering fails with ActiveModel-Object

I am setting up a rails5 project using OrientDB as Database (ActiveOrient, https://github.com/topofocus/active-orient) I have two Models "Basiswert" and "Aktie", both provide a method "...

Undefined method '+' for #<Class >

I created a Rails app to allow visitors to read magazines online. I created two scaffolds, one for the magazine itself and one for the pages inside the magazines, that will be scanned images. The ...

How to add history item from Redmine plugin using journal

I have update the meeting plugin. in this plugin when update the meeting it doesnot update the meeting history. like i change the subject for meeting it update the subject but dont update the history ...

Remove email field in devise gem?

I would like to NOT require email for signing only mobile number to register user and login in using devise gem. I removed email from config/initializers/devise.rb:

rails byebug vs. breakpoints

I don't understand the purpose of breakpoints when you can just put byebugs everywhere. Doesn't both tools just stop the program stack at certain points for you to see what variables are there and ...

nginx error /home/deploy/myapp/current/public/" is forbidden

I tried the solution of a similar question and many other on stackoverflow but none of them seem to solve this issue. The default niginx "Welcome" page was running even when I configured /etc/nginx/...

rails apartment gem copy data from one tenant to another

I am creating a multi-tenant rails app for technical training centers. I'm using the apartment gem so it creates different databases for each tuition center which has trainers and students. Students ...

ExecJS::ProgramError: SyntaxError: Unexpected token: name <ClassName>

I've created a JavaScript class (named as BarChart) that have constructor and several methods init. I executed below command to pre-compile assets for production environment but got error. Command ...

GitHub Enterprise OAuth returning incomplete user data (names missing) for users with accents in their names

I'm building a Rails application that allows users to authenticate with their Github Enterprise account. During this authentication step (using omniauth-github) I pick up some additional information ...

Rails real time app [on hold]

I am trying to build real time app using Ruby and Rails. Task (long story short): user submits jobs(fetching, pulling with interval - not a one-time shot), that evaluates on server (some background ...

Why is Rails/RSpec not able to render & in test?

I've got a mailer. And a view for that mailer. While in preview, everything looks fine, and links render properly. The problem is writing specs (RSpec). When I try to test the presence of some links ...

facebook redirect url not redirecting to intended url from facebook app

I have FB.init function to share on facebook. I am able to redirect to given redirect url through other browsers. But the same thing is not working on facebook app. It redirects me to the home url. ...

rspec; How to test this function?

ImageManager.check_enable_time def check_enable_time # get current time now_time = Time.now # UTC to JST convestion JST = UTC + 9 hours hour = now_time.in_time_zone("Asia/Tokyo").hour (...

Deploying to OpenBSD without a Ruby Manager (RBENV/RVM)

The package manager in OpenBSD has a good naming convention, so it's not necessary to include RVM or RBENV as a Ruby manager. I've read through the docs and it seems as though Capistrano requires ...

rails sunspot with polymorphic association

I have review model that act as polymorphic and it stores the reviews and ratings of different tables. What I need to do is, if I choose filter of rating from the form that has checkboxes with (1, 2, ...

Rails + CKEditor + Paperclip + AWS S3 to upload files in different folders

I was able to set up CKEditor to allow editing of Article model in my Rails app, and it will upload any images to AWS S3 via Paperclip. The upload is successful. However, all the images uploaded are ...

Bootstrap navbar appearing vertically instead of horizontal

Working on a project and my navbar is appearing as a vertical list instead of horizontally across the page. I've tried several different ways to fix and looked at other posts. I believe all my code is ...

ActiveRecord: Get all keys after group in single query

I have defined a scope that group a column. For example here is my short code: scope :active, lambda{ some query here } scope :product_active, lambda{ active.group(:product_id).select(:product_id) } ...

Rails. Has_many :through and form_for params for a checkbox field

So I have this kind of association: class FirstModel has_many :merged_models has_many :second_models, :through => :merged_models end class SecondModel has_many :merged_models has_many :...

ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file — selenium-webdriver (LoadError)

I am trying to run this below code, then I got code error: ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError) I am not able to ...
Translating... 0%