I am new to Rails and I am setting up the user profile and adding fields to 
it for users to add details to their profile such as career, about me, 
height, religion, etc. This information is completely different from the 
registration options (account settings). As of now the profile fields are 
being recognized as the registration fields, which is incorrect. When I 
click "Update" on profile page, it redirects to registration page. So the 
profile page with all those fields have no value atm. The system is not 
recogonizing that those values should be saved to the user profile. How it 
should work is when user goes to their page at /users/4 it will present 
forms for all their profile details. After selecting answers for each 
options, the user clicks the button "Update" and the profile information 
saves. The complete opposite is happening as of now, user clicks "Update" 
and it directs User back to the index (which is the register page) and it 
acts as if the previous page the User was on (profile page) was trying to 
fill out information from the registration form...which is incorrect.

Users_controller file (can also find all this information on 
https://gist.github.com/pwz2k/5047974) :

class UsersController < ApplicationController
>
>   def new
>
>     @user = User.new
>
>   end
>
>   
>
>   def create
>
>     @user = User.new(params[:user])
>
>     if @user.save
>
>       UserMailer.registration_confirmation(@user).deliver
>
>       session[:user_id] = @user.id
>
>       redirect_to root_url, notice: "Thank you for signing up!"
>
>     else
>
>       render "new"
>
>     end
>
>   end
>
>   
>
>   def show
>
>     @user = User.find(params[:id])
>
>   end
>
>   
>
>     def edit
>
>       @user = User.find(params[:id])
>
> end
>
>   
>
>   def index
>
>     @users = User.all
>
>   end
>
>   
>
>   def destroy
>
>      User.find(params[:id]).destroy
>
>      flash[:success] = "User deleted."
>
>      redirect_to users_url
>
>    end
>
>   
>
> def update
>
>     @user = User.find(params[:id])
>
>     if @user.update_attributes(params[:user])
>
>       flash[:success] = "Account updated"
>
>       redirect_to @user
>
>     else
>
>       render 'edit'
>
>     end
>
> end
>
> end
>
>


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+unsubscr...@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.


Reply via email to