Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## UserController
- def new
- @user = User.new
- @artist = Artist.new
- end
- def create
- logout_keeping_session!
- @user = User.new(params[:user])
- @artist = @user.build_artist(params[:artist])
- @user.register! if @user && @user.valid?
- success = @user && @user.valid?
- if success && @user.errors.empty?
- redirect_back_or_default('/')
- flash[:notice] = "Thanks for signing up! We're sending you an email with your activation code."
- else
- flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)."
- render :action => 'new'
- end
- end
- ## Artist Model
- class Artist < ActiveRecord::Base
- validates_presence_of :name
- validates_uniqueness_of :name, :case_sensitive => false
- end
- ## User:View:New
- <h1>Sign up as a new user</h1>
- <% @user.password = @user.password_confirmation = nil %>
- <%= error_messages_for :user %>
- <% form_for :user, :url => users_path do |f| -%>
- <p><label for="email">Email (this will be your login name)</label><br/>
- <%= f.text_field :email %></p>
- <p><label for="name">Artist Name</label><br/>
- <% fields_for "artist", @artist do |a| %>
- <%= a.text_field :name %>
- <% end %>
- <p><label for="password">Password</label><br/>
- <%= f.password_field :password %></p>
- <p><label for="password_confirmation">Confirm Password</label><br/>
- <%= f.password_field :password_confirmation %></p>
- <p><%= submit_tag 'Sign up' %></p>
- <% end -%>
Add Comment
Please, Sign In to add comment