ruby-on-rails-3

Rails pass request.subdomain into a custom Devise mailer layout

自古美人都是妖i 提交于 2020-05-10 14:15:04
问题 I need to adapt the forgot password instructions to handle a subdomain. I have followed the instructions on the devise site to override the mailer, controller and add a subdomain helper etc. as listed: controllers/password_controller.rb class PasswordsController < Devise::PasswordsController def create @subdomain = request.subdomain super end end routes.rb devise_for :users, controllers: { passwords: 'passwords' } devise.rb config.mailer = "UserMailer" mailers/user_mailer.rb class UserMailer

how to stop the install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` on the server

丶灬走出姿态 提交于 2020-04-30 07:22:19
问题 I'm deploying a app on production mode but when i try to finish the process the aways show this need for sqlite adapter, please someone know how to stop this issue? i've been using RAILS_ENV=production but in this case did not worked. current$ rails generate admin_interface:setup RAILS_ENV=production DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from warn at /home/ubuntu/.rbenv/versions/2.2.2/lib/ruby/2.2.0/forwardable.rb:183) /home/ubuntu/.rbenv/versions/2.2.2/lib

Execution order of multiple after_commit callbacks (Rails)

耗尽温柔 提交于 2020-03-21 19:07:14
问题 I recently found that multiple after_commit s defined in the same model get called in reverse order. For example after_commit method1, :on => :create after_commit method2, :on => :create method2 gets called before method1 . Is it always called in FILO order? 回答1: This behaviour is still present in Rails 5.2.2.1. My solution: after_commit :after_commit_callbacks, :on => :create def after_commit_callbacks method1 method2 end 来源: https://stackoverflow.com/questions/30625790/execution-order-of

Execution order of multiple after_commit callbacks (Rails)

不打扰是莪最后的温柔 提交于 2020-03-21 19:06:23
问题 I recently found that multiple after_commit s defined in the same model get called in reverse order. For example after_commit method1, :on => :create after_commit method2, :on => :create method2 gets called before method1 . Is it always called in FILO order? 回答1: This behaviour is still present in Rails 5.2.2.1. My solution: after_commit :after_commit_callbacks, :on => :create def after_commit_callbacks method1 method2 end 来源: https://stackoverflow.com/questions/30625790/execution-order-of

Execution order of multiple after_commit callbacks (Rails)

你离开我真会死。 提交于 2020-03-21 19:06:18
问题 I recently found that multiple after_commit s defined in the same model get called in reverse order. For example after_commit method1, :on => :create after_commit method2, :on => :create method2 gets called before method1 . Is it always called in FILO order? 回答1: This behaviour is still present in Rails 5.2.2.1. My solution: after_commit :after_commit_callbacks, :on => :create def after_commit_callbacks method1 method2 end 来源: https://stackoverflow.com/questions/30625790/execution-order-of

Rails: is there a way to tell the source of the request?

半腔热情 提交于 2020-03-16 05:20:28
问题 Google analytics tells me what the source of my traffic is (search engines, facebook etc). Is there a way to get this information for each request from the request object or otherwise? I'd appreciate any help. 回答1: request.referrer will give you the HTTP referrer value. 来源: https://stackoverflow.com/questions/6366935/rails-is-there-a-way-to-tell-the-source-of-the-request

Unpermitted Parameters: profile (NestedAttributes) - RAILS 4

回眸只為那壹抹淺笑 提交于 2020-03-05 05:39:50
问题 This question has many times asking by others user but still not solved my problem here. Im having a problem with my rails apps where error "Unpermitted Parameters: profile" appear. user_controller.rb class Admin::UsersController < ApplicationController before_filter :set_user, only: [:edit, :update] before_filter :store_location, only: [:index] before_filter :require_admin def edit if @user render else redirect_to admin_users_path, notice: "User profile not found." end end def update # Rails

Unpermitted Parameters: profile (NestedAttributes) - RAILS 4

﹥>﹥吖頭↗ 提交于 2020-03-05 05:39:49
问题 This question has many times asking by others user but still not solved my problem here. Im having a problem with my rails apps where error "Unpermitted Parameters: profile" appear. user_controller.rb class Admin::UsersController < ApplicationController before_filter :set_user, only: [:edit, :update] before_filter :store_location, only: [:index] before_filter :require_admin def edit if @user render else redirect_to admin_users_path, notice: "User profile not found." end end def update # Rails

Ruby Mongo Driver: How To Look For Date Intervals?

孤街浪徒 提交于 2020-03-05 03:09:52
问题 Given a init date and today, what's the query to search for all "names" between that date? Thank you 回答1: MongoMapper You should be able to use MongoMapper's query operators. Suppose your have a "User" model with a "created_on" date, you could use this to get the names. (I believe MongoDB uses UTC Times to store all date/time objects): initial_date = Time.utc(2011, 5, 1) # 2011-05-01 00:00:00 UTC @users = User.where(:created_on => {:$gte => initial_date, :$lte => Time.now.utc}) @users.each do

rails joins with module name

青春壹個敷衍的年華 提交于 2020-03-01 09:39:39
问题 Here is how to join two models User.where(:id => 1).joins(:posts) but how to join two models with module/namspace @schedules= Swimming::Classschedule.joins(:Swimming::Slot).where(:date => @date) seems not working properly (with error message) :Swimming is not a class/module UPDATE I have updated to @schedules= Swimming::Classschedule.joins(:swimming_slots).where(:date => @date) and I do have this table create_table :swimming_classschedules do |t| t.integer :slot_id t.integer :coach_id t