Users_controller file (can also find all this information on https://gist.github.com/pwz2k/5047974) :
class UsersController < ApplicationControllerdef new@user = User.newenddef create@user = User.new(params[:user])if @user.saveUserMailer.registration_confirmation(@user).deliversession[:user_id] = @user.idredirect_to root_url, notice: "Thank you for signing up!"elserender "new"endenddef show@user = User.find(params[:id])enddef edit@user = User.find(params[:id])enddef index@users = User.allenddef destroyUser.find(params[:id]).destroyflash[:success] = "User deleted."redirect_to users_urlenddef update@user = User.find(params[:id])if @user.update_attributes(params[:user])flash[:success] = "Account updated"redirect_to @userelserender 'edit'endendend
show.html file:
<h1><%= @user.username %></h1>
<h2>Basics</h2>
<%= form_for(@user, :url => {:action => :create}) do |f| %>
<div class="field">
<%= f.label :height %><br/>
<%= f.select :about_me, [['Feet', nil], '4', '5', '6'] %>
<%= f.select :about_me, [['Inches', nil], '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '10', '11'] %>
</div>
<div class="field">
<%= f.label :children %><br/>
<%= f.select :children, [['Do you have or want kids?', nil], 'Yes, they live with me', 'I want kids now', 'I want one someday', 'Not for me']%>
</div>
<div class="field">
<%= f.label :religion %><br/>
<%= f.select :religion, [['What is your faith?', nil], 'Agnostic', 'Atheist', 'Christian', 'Catholic', 'Buddhist', 'Hindu', 'Jewish', 'Muslim', 'Spiritual without affiliation', 'Other', 'None', 'Prefer not to say' ]%><br/>
<%= f.select :religion, [['How important is this to you?', nil], 'Very Important', 'Somewhat Important', 'Not Important']%>
</div>
<div class="field">
<%= f.label :career %><br/>
<%= f.text_field :career %>
</div>
<div class="field">
<%= f.label :education %><br/>
<%= f.select :education, [['What is your education level?', nil], 'High school', 'Some college', 'Undergraduate', "Bachelor's", "Master's ", 'PhD', 'Business school', 'Law school', 'Medical school' ]%>
</div>
<div class="field">
<%= f.label :ethnicity %><br/>
<%= f.select :ethnicity, [['What is your ethnicity?', nil], 'Asian', 'Black', 'Biracial', 'Indian', 'Hispanic/Latin', 'Middle Eastern', 'Native American', 'Pacific Islander', 'White', 'Other' ]%>
</div>
<%= f.label :user_drink %><br/>
<%= f.select :user_drink, [['How much do you drink?', nil], 'Often Drinks', 'Sometimes drinks', 'Never drinks', 'No comment' ]%>
</div><br/>
<%= f.label :user_smoke %><br/>
<%= f.select :user_smoke, [['How often do you smoke?', nil], 'Often smokes', 'Sometimes smokes', 'Never smokes'] %>
</div>
<div class="actions"><%= f.submit %></div>
<h3>About Me</h3>
<%= form_for @user do |f| %>
<div class="field">
<%= f.label :about_me %><br/>
<%= f.text_field :about_me %>
<div class="actions"><%= f.submit %></div>
<% end %>
<% end %>
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HPIn5dTfxI8J.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment