ruby

Sending emails on user-selected dates

本秂侑毒 提交于 2021-02-10 17:54:11
问题 My app involves people coming to a home page, entering a name of a bet they've made (for fun), their email address, a date they would like to be reminded, and some details about the bet. I am using the whenever gem to have this run once a day. bet.rb class Bet < ActiveRecord::Base attr_accessible :details, :email, :name, :reminder, :sent # Sends user a reminder if current_date is equal to the reminder date of the bet def check_bet current_date = Time.now.strftime("%Y-%m-%d").to_s @bets = Bet

Bundler could not find compatible versions for gem “rails” | In Gemfile: rails (~> 6.1.0) x64-mingw3

橙三吉。 提交于 2021-02-10 17:37:19
问题 I'm developing a new Ruby on Rails project with Spree Commerce and while running bundle install I'm getting the following error: Bundler could not find compatible versions for gem "rails": rails (~> 6.1.0) x64-mingw32 spree (~> 4.1) x64-mingw32 was resolved to 4.2.0.beta, which depends on spree_core (= 4.2.0.beta) was resolved to 4.2.0.beta, which depends on rails (~> 6.0.0) I'm following Spree Commerce Docs for its installation. I'm on Windows 10 , using Ruby 2.7.2 , Bundler 2.2.3 and Rails

uninitialized constant Ability Rails

孤街浪徒 提交于 2021-02-10 16:25:19
问题 I have gone through different solutions given to this problem but none of them is working so please don't try to close the question as duplicate. I have role column in my users table. So user can by admin or user and I need to put permissions on the base of user Role using CanCan . I want to give all permissions to admin. I am logged in as admin but when I access /users I get the error uninitialized constant Ability and when I remove load_and_authorize_resource my cancan permission doesn't

ArgumentError after updating from Ruby 2.7 to Ruby 3.0

无人久伴 提交于 2021-02-10 14:38:43
问题 When I try to update our site to Ruby 3.0.0 I get this error: ArgumentError (wrong number of arguments (given 2, expected 1)) % rails console Loading development environment (Rails 6.1.0) irb(main):001:0> puts RUBY_VERSION 3.0.0 irb(main):002:0> puts IceCube::VERSION 0.16.3 irb(main):003:0> schedule = IceCube::Schedule.new => #<IceCube::Schedule:0x00007fccfe19cfa8 @start_time=2020-12-27 11:14:30 -0800, @all_recurrence_rules=[], @all_exception_rules=[]> irb(main):004:0> puts schedule.to_ical

ArgumentError after updating from Ruby 2.7 to Ruby 3.0

情到浓时终转凉″ 提交于 2021-02-10 14:37:15
问题 When I try to update our site to Ruby 3.0.0 I get this error: ArgumentError (wrong number of arguments (given 2, expected 1)) % rails console Loading development environment (Rails 6.1.0) irb(main):001:0> puts RUBY_VERSION 3.0.0 irb(main):002:0> puts IceCube::VERSION 0.16.3 irb(main):003:0> schedule = IceCube::Schedule.new => #<IceCube::Schedule:0x00007fccfe19cfa8 @start_time=2020-12-27 11:14:30 -0800, @all_recurrence_rules=[], @all_exception_rules=[]> irb(main):004:0> puts schedule.to_ical

watir cannot create internet explorer browser - Enable Protected Mode issue

社会主义新天地 提交于 2021-02-10 14:26:50
问题 I am using the following code snippets to create internet explorer browser and do some testing. I am not able to create ie browser because of the exception given below. How do I fix this? require 'rubygems' require 'watir-webdriver' require 'phantomjs' client = Selenium::WebDriver::Remote::Http::Default.new client.timeout = 300 browser = Watir::Browser.new :ie, :http_client => client browser.goto "some url" Error - Started InternetExplorerDriver server (32-bit) 2.29.0.0 Listening on port 5555

Rails Env Issue

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:24:58
问题 So the other day I was trying to replicate some of the tests that were being ran by circleci and before some of the commands I called: export RAILS_ENV=test export RACK_ENV=test and now I guess the problem is that I seem to be stuck in test ? Also, I've tried executing those same commands except with each of the vars set to development, yet to no avail. Any ideas? 回答1: try 'unsetting' those env variables. export RAILS_ENV= export RACK_ENV= or try restarting the server to set them back to

Deploy error ruby on rails Don't know how to build task 'assets:precompile'?

送分小仙女□ 提交于 2021-02-10 14:24:05
问题 I try to run on Digitalocean cap production deploy but i got this this error 00:42 deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile 01 rake aborted! 01 Don't know how to build task 'assets:precompile' (See the list of available tasks with rake -… 01 /home/deploy/RubyProject/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in <top (requi… 01 /home/deploy/.rbenv/versions/2.6.6/bin/bundle:23:in load' 01 /home/deploy/.rbenv/versions/2.6.6/bin/bundle

Algorithm Ballots cast in an Election

末鹿安然 提交于 2021-02-10 14:20:50
问题 Can someone help me solve this? We recently held an election for 3 positions. There were 6 candidates. Each member could cast 3 votes but could not vote for the same person more than once. 134 ballots were cast. (402 total votes) The final tally was result = {a:91, b:66, c:63, d:63, e:60, f:59} I can easily determine the 20 possible unique ballots cast result.keys.combination(3).to_a But obviously given the number of possible combinations brute force would be impossibly time consuming so I am

How to use HTML ID in a ruby if statement condition

百般思念 提交于 2021-02-10 14:17:49
问题 I'm trying to render a form depending on which checkbox has been ticked. I want to use an if statement with the checkbox's id in the condition, but rails is throwing up an error 'undefined method tab1. Is there a way to target html in an if statement? thanks <input id="tab1" type="radio" name="tabs" checked> <label class="label-header" for="tab1"> UK Address</label> <input id="tab2" type="radio" name="tabs"> <label class="label-header"for="tab2"> International Address </label> <!-- <section