ruby-on-rails-3.2

SendGrid on Heroku fails

亡梦爱人 提交于 2021-02-16 16:38:11
问题 I setup send grid starter for my heroku app. I put this in my config/environment.rb: ActionMailer::Base.smtp_settings = { :user_name => ENV["SENDGRID_USERNAME"], :password => ENV["SENDGRID_PASSWORD"], :domain => "my-sites-domain.com", :address => "smtp.sendgrid.net", :port => 587, :authentication => :plain, :enable_starttls_auto => true } I create this class models/notifier.rb: class Notifier < ActionMailer::Base def notify() mail( :to => "my-email@gmail.com", :subject => "New Website Contact

SendGrid on Heroku fails

自古美人都是妖i 提交于 2021-02-16 16:37:32
问题 I setup send grid starter for my heroku app. I put this in my config/environment.rb: ActionMailer::Base.smtp_settings = { :user_name => ENV["SENDGRID_USERNAME"], :password => ENV["SENDGRID_PASSWORD"], :domain => "my-sites-domain.com", :address => "smtp.sendgrid.net", :port => 587, :authentication => :plain, :enable_starttls_auto => true } I create this class models/notifier.rb: class Notifier < ActionMailer::Base def notify() mail( :to => "my-email@gmail.com", :subject => "New Website Contact

pg_search for an advanced search

谁都会走 提交于 2021-02-11 05:52:43
问题 I'm trying to figure out how to pass multiple parameters to my search using pg_search_gem and the pg_search_scope This is my simple search include PgSearch pg_search_scope :simple_search, against: [:title, :description], using: { tsearch: { dictionary: "spanish"} } def self.search(search) if search.present? simple_search(search) else find(:all) end end But now I'm trying to do something like this include PgSearch pg_search_scope :simple_search, against: [:title, :place, :category], using: {

pg_search for an advanced search

狂风中的少年 提交于 2021-02-11 05:51:27
问题 I'm trying to figure out how to pass multiple parameters to my search using pg_search_gem and the pg_search_scope This is my simple search include PgSearch pg_search_scope :simple_search, against: [:title, :description], using: { tsearch: { dictionary: "spanish"} } def self.search(search) if search.present? simple_search(search) else find(:all) end end But now I'm trying to do something like this include PgSearch pg_search_scope :simple_search, against: [:title, :place, :category], using: {

How to display a Rails flash notice upon redirect?

若如初见. 提交于 2021-01-20 14:36:48
问题 I have the following code in a Rails controller: flash.now[:notice] = 'Successfully checked in' redirect_to check_in_path Then in the /check_in view: <p id="notice"><%= notice %></p> However, the notice does not show up. Works perfect if I don't redirect in the controller: flash.now[:notice] = 'Successfully checked in' render action: 'check_in' I need a redirect though... not just a rendering of that action. Can I have a flash notice after redirecting? 回答1: Remove the .now . So just write:

What is the difference between Rails.cache.clear and rake tmp:cache:clear?

梦想的初衷 提交于 2020-11-30 02:45:28
问题 Are the two commands equivalent? If not, what's the difference? 回答1: The rake task only clears out files that are stored on the filesystem in "#{Rails.root}/tmp/cache" . Here's the code for that task. namespace :cache do # desc "Clears all files and directories in tmp/cache" task :clear do FileUtils.rm_rf(Dir['tmp/cache/[^.]*']) end end https://github.com/rails/rails/blob/ef5d85709d346e55827e88f53430a2cbe1e5fb9e/railties/lib/rails/tasks/tmp.rake#L25-L30 Rails.cache.clear will do different

What is the difference between Rails.cache.clear and rake tmp:cache:clear?

若如初见. 提交于 2020-11-30 02:45:08
问题 Are the two commands equivalent? If not, what's the difference? 回答1: The rake task only clears out files that are stored on the filesystem in "#{Rails.root}/tmp/cache" . Here's the code for that task. namespace :cache do # desc "Clears all files and directories in tmp/cache" task :clear do FileUtils.rm_rf(Dir['tmp/cache/[^.]*']) end end https://github.com/rails/rails/blob/ef5d85709d346e55827e88f53430a2cbe1e5fb9e/railties/lib/rails/tasks/tmp.rake#L25-L30 Rails.cache.clear will do different

What is the difference between Rails.cache.clear and rake tmp:cache:clear?

喜夏-厌秋 提交于 2020-11-30 02:44:59
问题 Are the two commands equivalent? If not, what's the difference? 回答1: The rake task only clears out files that are stored on the filesystem in "#{Rails.root}/tmp/cache" . Here's the code for that task. namespace :cache do # desc "Clears all files and directories in tmp/cache" task :clear do FileUtils.rm_rf(Dir['tmp/cache/[^.]*']) end end https://github.com/rails/rails/blob/ef5d85709d346e55827e88f53430a2cbe1e5fb9e/railties/lib/rails/tasks/tmp.rake#L25-L30 Rails.cache.clear will do different