简体   繁体   中英

RoR devise custom sign up page

am using devise with simple_form, can't seem to get a simple sign up working on a view that isn't generated by devise. Any help is appreciated!

= simple_form_for @user do |f|
 = f.input :email
 = f.input :password
 = f.input :password_confirmation
 = f.submit "Create", class: "btn btn-blue"

Controller:

def set_user
@user = params[:id] ? User.find(params[:id]) : User.new
end

def new
end

 def create
  @user = User.new(user_params)
  respond_to do |format|
    if @user.save
      redirect_to overview_path, notice: "logged in"
     else
      format.html { render action: 'new' }
      format.json { render json: @event.errors, status: :unprocessable_entity }
   end
 end
end

Also, the params being passed in:

user[email]:lol@lol.com
user[password]:123123
user[password_confirmation]:123123
commit:Sign up

but @user.password = nil, and it returns an error!

Thanks in advance!

In your controller do you have something like this? (or is yours attr_accessible?)

def post_params
   params.require(:user).permit(:email,:password)
end

Check your routes to see if your path is being changed. That is you would have your own controller and so the path has to be defined something like

devise_for :users, :controllers => { :registrations => 'registrations' }

Devise comes with default views for sign-in/sign-out. In order to override the Devise views, you need to generate them first using:

rails generate devise:views

From there, you can go to app\\views\\devise\\sessions\\new and change the standard template. That is the simplest way from my experience.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM