Skip to content

Instantly share code, notes, and snippets.

View account_created_feature_spec.rb
RSpec.describe "Account", :type => :system do
it "creates an account" do
name = Faker::Name.name
email = Faker::Internet.email
password = Faker::Alphanumeric.alphanumeric(number: 10)
visit sign_up_path
within("#new_account") do
View gist:0371646af3a9c20f371c29261f4cea53
class ActiveStorage::BaseController < ApplicationController
include ActiveStorage::SetCurrent
before_action :authenticate_user!
protect_from_forgery with: :exception
def authenticate_user!
if current_user
else
View index.haml
= form_tag "/admin/users/#{:id}/edit", method: :get do
.row
.col-sm-12.col-md-9
= select_tag :id, options_from_collection_for_select(User.all, 'id', 'name',{ prompt: 'Find User' }), class: 'form-control select2'
View gist:66c38536bcd2238282815c5e4d74538a
SELECT id FROM `caffeine_product_options`WHERE `product_option_title` = "we start with 5";
UPDATE caffeine_product_options SET option_qty = option_qty - '$quantity' WHERE id= is_set_from_select
View gist:0adb22bdd9bbf58ce6c6940e18cf71e6
ActionView::Template::Error (undefined method `to_datetime' for 0:Fixnum):
208: <div class="col-sm-4 col-xs-7">
209: <%= f.select :dob_month, ['01', '02', '03','04', '05', '06','07', '08', '09','10', '11', '12'], :class => "float-right number", :prompt => "Month" %>
210: <%= f.select :dob_day, ['01', '02', '03','04', '05', '06','07', '08', '09','10', '11', '12','13', '14', '15','16', '17', '18','19', '20', '21','22','23', '24', '25','26', '27', '28','29', '30','31'], :class => "form-control margin-ten no-letter number", :prompt => "Day" %>
211: <%= f.date_select :dob_year, {:order => [:year], :start_year => 1920, :end_year => Time.now.year, :prompt => "Year" }, {:class => "texter"} %>
212: </div>
213: </div>
214: </div>
app/views/devise/registrations/_registrations.html.erb:211:in `block in _app_views_devise_registrations__registrations_html_erb__4136954747110916622_70221770454860'
app/views/devise/registrations/_registrations.html.erb:
@staycreativedesign
staycreativedesign / gist:8a2261a1765dd9ba2da1161342a3d32a
Created May 19, 2020
I'm pretty sure that dob_year is coming back as an integer?
View gist:8a2261a1765dd9ba2da1161342a3d32a
<%= f.date_select :dob_year, :start_year => 1995, :use_month_numbers => true %>
ActionView::Template::Error (undefined method `to_datetime' for 0:Fixnum):
208: <div class="col-sm-4 col-xs-7">
1'], :class => "form-control margin-ten no-letter number", :prompt => "Day" %>
211: <%= f.date_select :dob_year, {:order => [:year], :start_year => 1920, :end_year => Date.today.year, :prompt => "Year" }, {:class => "texter"} %>
213: </div>
214: </div>
View notifications_mailer.rb
class NotificationsMailer < ApplicationMailer
def notify(params)
@subject = params[:notification][:subject]
@message = params[:notification][:message]
users = params[:notification][:user_ids].reject(&:blank?)
additional_emails = params[:notification][:emails]
marketers = params[:notification][:marketer_ids].reject(&:blank?)
documents = params[:notification][:document_ids].reject(&:blank?)
state = params[:notification][:state]
View gist:20a369fd47e18a35e6256e975f984d3a
def find_emails_from_extra(search_term, name )
emails = []
emails << User.where(search_term: name).pluck(:email)
emails
end
how can I change the search_term: into whatever the attribute is?
so if I do
find_email_from_extra(employer_state, "FL")
View gist:3101126bc3377aa807f9e268ab84acfa
[
['Alabama', 'AL'],
['Alaska', 'AK'],
['Arizona', 'AZ'],
['Arkansas', 'AR'],
['California', 'CA'],
['Colorado', 'CO'],
['Connecticut', 'CT'],
['Delaware', 'DE'],
['District Of Columbia', 'DC'],
View outcome.rb
Document(#70259050585960) expected, got "" which is an instance of String(#70259013172680)
class Notification < ApplicationRecord
has_and_belongs_to_many :documents
has_many :users
has_many :marketers
end