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 8390659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:03:24+00:00 2026-06-09T19:03:24+00:00

I have a standard devise edit user form: <%= form_for(resource, :as => resource_name, :url

  • 0

I have a standard devise edit user form:

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
  <%= devise_error_messages! %>

  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
  <%= f.password_field :password, :autocomplete => "off" %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

  <p>Current Photo</p>
  <%= image_tag @user.photo.url %>

   <%= f.file_field :photo %>

  <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
  <%= f.password_field :current_password %></div>

  <div><%= f.submit "Update" %></div>
<% end %>

Now, Rails, obviously complains because of the line: <%= image_tag @user.photo.url %> since there isn’t an @user in the edit action of the devise controller. Usually, I’d be able to just put @user = current_user in the controller and be done.

The goal is to show the user what their current photo is before they upload a new one. What’s the best way to do that?

  • 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-06-09T19:03:26+00:00Added an answer on June 9, 2026 at 7:03 pm

    If User is the only resource that will use devise, you could use resource.photo.url.

    If there are some different classes that will authenticate with devise, but will not have a photo, you could use resource.respond_to?(:photo) to include the photo and photo fields like this:

    <% if resource.respond_to?(:photo) %>
      <p>Current Photo</p>
      <%= image_tag resource.photo.url %>
    
      <%= f.file_field :photo %>
    <% end %>
    

    That way, you only include the photo information when the class has a photo attribute

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standard form array in PHP like this. I need to account
I'm using Rails 3 with Devise for user auth. Let's say I have a
On core website I use standard Devise configuration for user authentication. In routes.rb: devise_for
I have users class User < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable attr_accessible
It seems when a user logs out via standard Devise controllers, Devise destroys the
I have standard source code package under Linux which requires to run ./configure make
Is it possible to have standard war deployment, which can be deployed on tomcat
I've heard they have standard GUI guideline, but I can't seem to find a
I have a mobile site running with jQuery Mobile. I want to have standard
I have a standard table: I want to use jQuery to reformat the table,

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.