Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial ruby support. #8

Merged
merged 2 commits into from
Dec 30, 2015
Merged

Initial ruby support. #8

merged 2 commits into from
Dec 30, 2015

Conversation

Eric-Guo
Copy link
Contributor

No description provided.

@ctf0
Copy link
Owner

ctf0 commented Dec 29, 2015

could u also add a screen shot for it and update the readme ?

@Eric-Guo
Copy link
Contributor Author

with pressure 😄

@ctf0
Copy link
Owner

ctf0 commented Dec 30, 2015

LOL, thanx 🤘
if its okay with u ,i may change the HL later to match the overall colors
can u send me some code to test with ?

ctf0 pushed a commit that referenced this pull request Dec 30, 2015
@ctf0 ctf0 merged commit b5e775c into ctf0:master Dec 30, 2015
@Eric-Guo
Copy link
Contributor Author

I think below code is pretty good as almost all element is include.

Thanks your effort to adjust the right color.

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :authenticate_user!

  before_action :configure_permitted_parameters, if: :devise_controller?

  before_action :set_current_user

  def render_404
    render_optional_error_file(404)
  end

  def render_optional_error_file(status_code)
    status = status_code.to_s
    fname = %w(404 403 422 500).include?(status) ? status : 'unknown'
    render template: "/errors/#{fname}", format: [:html],
           handler: [:erb], status: status, layout: 'application'
  end

  rescue_from ActionController::InvalidAuthenticityToken do |_exception|
    redirect_to new_user_session_path, alert: '请先登录。'
  end

  private

  def set_current_user
    User.current_user = current_user
  end

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:account_update) do |u|
      u.permit(:password, :password_confirmation, :current_password, :name)
    end
    devise_parameter_sanitizer.for(:sign_in) do |u|
      u.permit(:name, :email, :password, :remember_me)
    end
  end
end

@ctf0
Copy link
Owner

ctf0 commented Dec 30, 2015

thanx :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants