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 > > else > > 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 %>
on 2013-02-27 21:48
on 2013-02-27 22:00
On 27 February 2013 16:40, C Wilson <cwilson05@gmail.com> wrote:
> I am new to Rails
Have you worked right through a good Rails tutorial such as
railstutorial.org in order to understand the basics of Rails? If not
then do that first.
If you have already done that then have a look at the Rails Guide on
debugging which will show you techniques that you can use to debug
your code and work out what is going wrong. The first thing you must
do is understand why it is doing what it is doing, then you can work
out how to fix it.
Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.