Skip to content

Instantly share code, notes, and snippets.

@dennismonsewicz
Last active January 4, 2016 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennismonsewicz/7bfa8e50f8d3e0ae8724 to your computer and use it in GitHub Desktop.
Save dennismonsewicz/7bfa8e50f8d3e0ae8724 to your computer and use it in GitHub Desktop.
Bad Example
# 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