Skip to content

Instantly share code, notes, and snippets.

@tochman
Last active December 30, 2015 03:09
Show Gist options
  • Save tochman/7767365 to your computer and use it in GitHub Desktop.
Save tochman/7767365 to your computer and use it in GitHub Desktop.
Fields for Avatar upload using carrierwave
<div class="collapse" id="register">
<%= form_for(resource, :class => "collapse", :html => { :id => "registerForm", :multipart => true }, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<!--[if lt IE 9]>
<label for="user_password">Enter email</label>
<![endif]-->
<%= f.email_field :email, :autofocus => true, :id => 'signup_email', :name => 'user[email]', :placeholder => "you@example.com" %>
<!--[if lt IE 9]>
<label for="user_password">Enter password</label>
<![endif]-->
<%= f.password_field :password, :id => 'signup_password', :name => 'user[password]', :placeholder => "password" %>
<!--[if lt IE 9]>
<label for="user_password">Confirm password</label>
<![endif]-->
<%= f.password_field :password_confirmation, :id => 'signup_password_confirmation', :placeholder => 'confirm password' %>
<!--[if lt IE 9]>
<label>My Avatar</label>
<![endif]-->
<%= f.file_field :avatar, :placeholder => 'your avatar' %>
<%= f.hidden_field :avatar_cache %>
<div><%= f.submit "Sign up", :id => 'signup', :class => "btn btn-primary" %></div>
<% end %>
</div>
<section id="devise">
<h2>Sign up</h2>
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :input_html => {:multipart => true}) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :email, :required => true, :autofocus => true %>
<%= f.input :password, :required => true %>
<%= f.input :password_confirmation, :required => true %>
<% if @user.avatar.url.present? %>
<%= image_tag(@user.avatar_url.to_s) %>
<% end %>
<%= f.file_field :avatar, :placeholder => 'your avatar' %>
<%= f.hidden_field :avatar_cache %>
</div>
<div class="form-actions">
<%= f.button :submit, "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
</section>
@tochman
Copy link
Author

tochman commented Dec 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment