Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:55:42+00:00 2026-05-31T14:55:42+00:00

I have a pretty basic ‘User’ model, control & views for a Rails app.

  • 0

I have a pretty basic ‘User’ model, control & views for a Rails app. I am trying to add a ‘profile’ section where the user can update their user info after logging in (and storing their user_id as a session variable).

I have scaffolded a basic ‘profile’ model, controller and views (_form, index and edit all using simple_form). The model is empty and the views are pretty much a copy of the user views except I have moved the ‘show’ format to the profile index view. In my controller I pretty much copied the user controller, deleted the new, create, show and destroy actions.

Here is what I have:

class ProfileController < ApplicationController
  def index
    @profile = User.find(session[:user_id])
  end

  def edit
    @profile = User.find(session[:user_id])
  end

  def update
    @profile = User.find(session[:user_id])

    respond_to do |format|
      if @profile.update_attributes(params[:profile])
        redirect_to @profile, notice: 'Profile was successfully updated.'
      else
        render action: "edit"
      end
    end
  end

 end

I tried both of these routes formats:

  match "profile" => "profile#index"  
  match "profile/edit" => "profile#edit"
  match "profile/update" => "profile#update"

and

  controller :profile do
    put 'profile/update' => :update
    get 'profile' => :index
    get 'profile/edit' => :edit
  end

When I load ~/profile/edit/ the form renders properly and my fields populate. I am using simple_form and here is the start of my _form.html.erb file:

<%= simple_form_for @profile, :url => url_for(:action => 'update', :controller => 'profile'), :html => { :id => "edit_profile", :class => 'form-horizontal' }, :method => 'put' do |f| %>

but simple_form still passes for="user_***" to all the field inputs.

I updated @profile.update_attributes(params[:profile]) to @profile.update_attributes(params[:user]) thinking that was the issue. When I click ‘Update User’ (still references the User model). The form reloads to ~/profile/update but nothing happens.

I am pretty sure I am missing an obvious routing / model issue here but I can’t seem to figure this out on my own.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:55:44+00:00Added an answer on May 31, 2026 at 2:55 pm

    I presume its not a routing / model issue here. Your edit profile page still references user because your @profile is a User and not a Profile.

    First, if you want to follow Rails’ convention, which I strongly recommend, use plural form for controller’s class as class ProfilesController < ApplicationController.

    Then, define routes for your profiles resource as resources :profiles, :only => [:index, :edit, :update]

    Your profiles#edit as :

    def edit
      @profile = User.find(session[:user_id]).profile #(i.e. if user has_one profile)
      # or @profile = Profile.find(params[:id) depending on what params are being passed here
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that is pretty basic. It contains several TextBox controls,
i have a pretty basic jquery question. im trying to add jscrollpane to my
I have a pretty basic Paperclip Upload model that is attached to a User
I have a pretty basic windows form app in .Net. All the code is
I am writing a pretty basic php app and have created a pretty big
I have a pretty basic app flow that is quite linear, so it fits
Pretty basic question: I have a model x that has_many y, and model y
I have the following: User has_many Listings Listing has_many Offers Pretty basic. A user
I have a pretty basic X11 app that I run on Linux that I'm
I have a pretty basic challenge-based iPhone game, and I wanted to know what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.