-
-
Save dennismonsewicz/7bfa8e50f8d3e0ae8724 to your computer and use it in GitHub Desktop.
Bad Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User Model | |
class User < ActiveRecord::Base | |
attr_accessible :first_name, :last_name, :admin, :email | |
end | |
# Users Controller | |
class Users < ApplicationController | |
def new | |
@user = User.new | |
end | |
def create | |
@user = User.new(params[:user]) | |
if @user.save | |
redirect_to users_path, notice: "User Created!" | |
else | |
render :new | |
end | |
end | |
end | |
# User Form | |
<%= form_for @user do |f| %> | |
<%= f.hidden_field :admin, value: true %> | |
<p><%= f.email_field :email, placeholder: "Email Address" %></p> | |
<p><%= f.text_field :first_name, placeholder: "First Name" %></p> | |
<p><%= f.text_field :last_name, placeholder: "Last Name" %></p> | |
<p><%= f.submit "Submit" %></p> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment