Here I'll show you
- How to override devise registrations_controller(related to create/update user account)
- How to change redirect path after updating user
| # original | |
| active_if any(:staff_beta?, :qa_ext_target?) | |
| # In addition to above, I want to active extension when controller is `professional_users` | |
| active_if do |context, options| | |
| user = context.instance_variable_get("@login_user") | |
| next unless user | |
| next true if user.staff? | |
| next true if user.release_target?(ReleaseTarget::QA_EXT_RELEASE_GROUP) |
| validates_format_of :locale, with: /^[a-z]{2}(?:-[A-Z]{2})?$/, allow_blank: true | |
| # valid: 'ja-JP', 'en' |
| n = Notification::Answer.new | |
| n.class.name.split('::').last || '' | |
| # => "Answer" | |
| n.class.name.split('::').first || '' | |
| # => "Notification" |
| Topic.includes(:tag,:user).paginate(:page => params[:page], :per_page => 15) |
| config.autoload_paths += %W( #{ config.root }/lib/middleware ) |
| validates :nickname, presence: true, length: 3..10, uniqueness: true, format: { without: /[!-\/\@\^\~\`\(\)\[\]\>\<\=]/ } |
| def redirect_back_or_default(default) | |
| redirect_to(session[:return_to] || default) | |
| session[:return_to] = nil | |
| end | |
| def redirect_referrer_or_default(default) | |
| redirect_to(request.referrer || default) | |
| end |
| git config --global core.excludesfile ~/.gitignore_global |
| # add min_messages to test env | |
| test: | |
| adapter: postgresql | |
| encoding: unicode | |
| database: homu_test | |
| pool: 5 | |
| username: postgres | |
| password: | |
| min_messages: warning |