Rails model validation - undefined method error

i'm trying to validate the presence on a parameter in rails. this is the code snippet for User.rb validates :terms_of_service, presence: true validates :privacy_policy, presence: true Ideally , i would like rails to throw an error if this par...
more »

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

Unable to install any ruby gems

I am trying to install Rails on my Mac. I keep getting a Jruby error or something of the sort: gem install rails Loading jruby-openssl in a non-JRuby interpreter Error loading RubyGems plugin "/Users/User/.rvm/gems/ruby-2.4.0@global/gems/executable-...
more »

2017-03-19 02:03 (0) Answers

Send Email to Multiple Recepients in Ruby on Rails

I want to send Email to Student and Guardian. I have 3 tables Student,Guardian and Users. The Student and Guardian are also in User table. But when i send an email its taking the email address of the First User instead of the Guardian. This is my Cod...
more »

2017-03-18 15:03 (0) Answers

Admin user allow to delete and edit other users

I have a problem with my users-controller. Currently, an admin user can delete itself, other users can not delete themselves. In addition, each user can edit themselves. However, I would like an admin user to delete and edit itself and others. How i...
more »

2017-03-18 14:03 (1) Answers

handling time distinct from datetime

The goal is to compare timestamp to a range of times. The range of times were defined in the rails schema as t.time for postgresql database. However the data returned upon querying the console attributes a date to the record's field... start_time:...
more »

2017-03-18 12:03 (3) Answers

Ruby: Iterating through dir's and files

I wrote the following script to iterate through a directory, it's subdirectories and their files: def self.search_files_in_dir_for(dir, strings) results = {} puts "Initializing test ..." Dir.foreach(dir) do |file| ...
more »

2017-03-17 22:03 (1) Answers

Rails Asset Pipeline problems with jquery-ui

Update I downloaded the latest version of jquery 3.1 and jquery-ui from the jquery website. Unluckly this problem with the .effect() function is not connected to the asset pipeline. I had all the required js and css files included, but .effect() wou...
more »

2017-03-17 16:03 (1) Answers

Rubygem: How to load information of a yaml file

My gem generates the following file into config/my_gem.yml: test: true Now I want to load the value of test into my gems module to be able to call: MyGem.test => true That was my attempt: In the Rails App - config/initializers/my_gem.rb: ...
more »

2017-03-16 20:03 (2) Answers

Rails # within HTML href comments out the line

In my controller I am setting a variable equal to an HTML string in order to account for a base case. However, # comments out the rest of the line. How can I escape this? @chart_data = "<p id='chart-notice'>If you <a href="#SOME_ID">logi...
more »

2017-03-16 18:03 (2) Answers

Replace until all occurences are removed

I have the following strings: ",||||||||||||||" ",|||||a|||||,|" I would like to achieve that all occurrences of ",|" are replaced with ",," The output should be the following: ",,,,,,,,,,,,,,," ",,,,,,a|||||,," When I run .gsub(',|', ',,') on...
more »

2017-03-16 12:03 (4) Answers

can't install mysql2 using gem

I am trying to create a project with mysql as database using rails I use the following command : gem install mysql2 I get the following result in commandline : Building native extensions. This could take a while... ERROR: Error installing my...
more »

2017-03-16 07:03 (1) Answers

How to fix aborting Fibonacci sequence code

I am trying to get a Fibonacci sequence of 5 million elements. This code aborts abnormally, when I pass 1000 as a parameter. def self.fibo_seq(limit) result_array = [0,1] return result_array if limit < 2 while result_array.length <= l...
more »

2017-03-15 19:03 (4) Answers

Rails form preview page

I want to save the Job data in the database, and redirect to a preview page (instead of the show page) which displays all the information from the Job form just submitted (essentially a duplicate of the show.html.erb page). Currently, when the user...
more »

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

ruby on rails, rails admin fieldset behavior

I working as intern for a webapp, they are using ruby on rails v4.2 and ruby v2.0.0, and rails admin v0.6.8. There is a problem in rails admin that arrived since Friday, after a commit, do I look on github each diff in each commit, and the problem ...
more »

2017-03-15 15:03 (0) Answers

How to quickly join two strings in Ruby

It's common to need to join strings, and in Ruby we have common ways of doing it: appending, concatenating and interpolating one into the other, or using the built-in concat method in String. (We have multiple ways of doing it for flexibility and to ...
more »

2017-03-14 18:03 (1) Answers

Wicked gem and POST method while submitting form

from my WizardController i've defined N steps. The first one includes a form (method: put) and a file upload field (image) handled through CarrierWave. While submitting the form without changing the image, Rails triggers the PUT method while if the...
more »

2017-03-14 11:03 (0) Answers

Is there a limitation for Faye subscribers?

Faye service is used for publish-subscribe messaging system. I am using it for Ruby. I can't find the information what is the limitation on the number of subscribers to a channel? For example, if I have a 1000 subscribers to a channel /notificatio...
more »

2017-03-13 11:03 (0) 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

Stripe charge. Couldn't find Product with 'id'=

I'm pretty new in Rails. In my project im using Stripe and I've been trying to make a charge. But every time when I try to run it I got this error. I've spent two days reading and searching, but I dont know what's wrong with it: ActiveRecord::Record...
more »

2017-03-12 17:03 (4) Answers