Skip to content

Instantly share code, notes, and snippets.

@caironoleto
Forked from anonymous/edit.html.erb
Created January 21, 2012 19:09
Show Gist options
  • Save caironoleto/1653617 to your computer and use it in GitHub Desktop.
Save caironoleto/1653617 to your computer and use it in GitHub Desktop.
Model
<div id="content-outer">
<!-- start content -->
<div id="content">
<div id="page-heading"><h1>Editando Usuário <%= @user.id %></h1></div>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<th rowspan="3" class="sized"><%= image_tag("/images/shared/side_shadowleft.jpg", :width => '20', :height => '300') %></th>
<th class="topleft"></th>
<td id="tbl-border-top">&nbsp;</td>
<th class="topright"></th>
<th rowspan="3" class="sized"><%= image_tag("/images/shared/side_shadowright.jpg", :width => '20', :height => '300') %></th>
</tr>
<tr>
<td id="tbl-border-left"></td>
<td>
<!-- start content-table-inner -->
<div id="content-table-inner">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td>
<!-- start id-form -->
<%= form_for @user, :url => admin_user_path(@user) do |f| %>
<% if @user.errors.any? %>
<div id="table-content">
<div id="message-red">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="red-left"><%= pluralize(@user.errors.count, "erros") %> proíbem este usuário de ser atualizado:</a></td>
<td class="red-right"><a class="close-red"><%= image_tag("/images/table/icon_close_red.gif") %></a></td>
</tr>
</table>
</div>
<% @user.errors.full_messages.each do |msg| %>
<div id="message-yellow">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="yellow-left"><%= msg %> <a href="">Go to Inbox.</a></td>
<td class="yellow-right"><a class="close-yellow"><%= image_tag("/images/table/icon_close_yellow.gif") %></a></td>
</tr>
</table>
</div>
<% end %>
</div>
<% end %>
<table border="0" cellpadding="0" cellspacing="0" id="id-form">
<tr>
<th valign="top">Nome</th>
<td><%= f.text_field :name, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Altera o seu nome!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Celular:</th>
<td><%= f.text_field :cell, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Altera o seu número de celular!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Telefone</th>
<td><%= f.text_field :phone, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Altera o seu número de telefone fixo!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Email:</th>
<td><%= f.text_field :email, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Altera o seu email de acesso ao site!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Descrição</th>
<td><%= f.text_area :description, :class => "form-textarea" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Altera sua descrição (deixe sempre atualizada)</div>
<div class="bubble-right"></div>
</td>
</tr>
<% if current_user.admin %>
<tr>
<th valign="top">Ativado?</th>
<td><%= f.check_box :actived, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Ativar este usuário!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Administrador?</th>
<td><%= f.check_box :admin, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Tornar este usuário administrador do site!</div>
<div class="bubble-right"></div>
</td>
</tr>
<tr>
<th valign="top">Parceiro?</th>
<td><%= f.check_box :partner, :class => "inp-form" %></td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Torna este usuário um parceiro do site!</div>
<div class="bubble-right"></div>
</td>
</tr>
<% end %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<% if !f.object.persisted? %>
<%= f.hidden_field :password, :value => @user.encrypted_password %>
<%= f.hidden_field :password_confirmation, :value => @user.encrypted_password %>
<% end %>
<tr>
<th>&nbsp;</th>
<td valign="top">
<%= f.submit "Enviar", :class => "form-submit" %>
<input type="reset" value="" class="form-reset" />
</td>
<td>
<div class="bubble-left"></div>
<div class="bubble-inner">Clique "Submit" para atualizar os dados ou "Reset" para limpar os dados.</div>
<div class="bubble-right"></div>
</td>
</tr>
</table>
<% end %>
<!-- end id-form -->
</td>
</tr>
<tr>
<td><%= image_tag("/images/shared/blank.gif", :width => '695', :height => '1') %></td>
<td></td>
</tr>
</table>
<div class="clear"></div>
</div>
<!-- end content-table-inner -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
<th class="sized bottomleft"></th>
<td id="tbl-border-bottom">&nbsp;</td>
<th class="sized bottomright"></th>
</tr>
</table>
<div class="clear">&nbsp;</div>
</div>
<!-- end content -->
<div class="clear">&nbsp;</div>
</div>
<%= link_to 'Mostrar', admin_imovel_path(@imovel) %> |
<%= link_to 'Voltar', admin_imoveis_path %>
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me,
:name, :cell, :phone, :description, :actived, :admin, :partner
has_many :imoveis, :dependent => :destroy
validates_uniqueness_of :email, :message => "ja existente. tente outro email"
validates :email, :presence => { :message => "precisa ser preenchido." }
validates_presence_of :password, :password_confirmation, :allow_nil => true
validates :name, :description, :presence => { :message => "precisa ser preenchido." }
validates :cell, :phone, :presence => { :message => "precisa ser preenchido." }
end
class Admin::UsersController < ApplicationController
layout "gerenciador"
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
# GET /imoveis
# GET /imoveis.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /imoveis/1
# GET /imoveis/1.xml
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
# GET /imoveis/new
# GET /imoveis/new.xml
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
# GET /imoveis/1/edit
def edit
@user = User.find(params[:id])
end
# POST /imoveis
# POST /imoveis.xml
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to(admin_user_path(@user), :notice => 'Usuario criado com sucesso!') }
format.xml { render :xml => @user, :status => :created, :location => @user }
else
format.html { render :action => "new" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
# PUT /imoveis/1
# PUT /imoveis/1.xml
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_without_password(params[:user])
format.html { redirect_to(admin_user_path(@user), :notice => 'Usuario atualizado com sucesso!') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /imoveis/1
# DELETE /imoveis/1.xml
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(admin_users_url, :notice => 'Usuario removido com sucesso!') }
format.xml { head :ok }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment