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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:53:03+00:00 2026-06-14T02:53:03+00:00

I have an model called Purchase.rb. each purchase is created through a form as

  • 0

I have an model called Purchase.rb. each purchase is created through a form as follows.

<%= form_for(@purchase) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_field :content, placeholder: "Describe something you are interested in buying.", :maxlength=>"254" %>
    <%= f.file_field :photo %>

  </div>
  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

when they are created they are displayed with a partial stored in app/views/purchases/_purchase.html.erb. To add photos, I have put

<%= form_for(@purchase) do |f| %>
    <%= f.file_field :photo %>
    <%= f.submit "Post", class: "btn btn-large btn-primary" %>
  <% end %>

in the purchase itself. I am using paperclip. So the idea is that people can click on a field that is part of the purchase and add a photo to the view.

the error I get says

Missing template purchases/users#show, application/users#show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/home/alex/rails_projects/tradespring!/app/views"

I want it to look at app/views/users#show, not app/views/purchases/users#show

edit:

here is the show action of the userscontroller:

class UsersController < ApplicationController


  def show
    @user = User.find(params[:id])
    @purchases= @user.purchases
    @sales= @user.sales
    @purchase=Purchase.new
    @sale=Sale.new
  end

and here is the routes.rb

Tradespring::Application.routes.draw do
  resources :users do
    resources :pcomments
    resources :scomments
  end
  resources :sessions, only: [:new, :create, :destroy]
  resources :purchases do
    resources :pcomments
  end
  resources :sales do
    resources :scomments
  end

  get "static_pages/home"

  get "static_pages/about"

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new' 
  match '/about',   to: 'static_pages#about'
  match '/signout', to: 'sessions#destroy', via: :delete

  root to: 'static_pages#home'

finally, here is the what I want to happen when I submit the picture form. Im not 100% sure it should be under update.

class PurchasesController < ApplicationController
 def update
    @purchase = Purchase.find(params[:id])
    if @purchase.update_attributes(params[:purchase])
      flash[:success] = "Picture added"

      redirect_to :back
    else
      render 'users/show'
    end
  end

also here is the app/views/user/show.html.erb

<% provide(:title, @user.name) %>
<p>
<%= mail_to(@user.email, name="email this user", :encode => "javascript") %>
</p>

<div id="purchases">

<%= form_for(@purchase) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_field :content, placeholder: "Describe something you are interested in buying.", :maxlength=>"254" %>
    <%= f.file_field :photo %>
    <p1> Note: There is a 254 character limit. Be sure to include useful information such as product specifications, how much you are willing to pay, and shipping info (where you live, if you want to pick it up locally, ect.). Further detail is best left to email.</p1>
  </div>
  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

<% if @user.purchases.any? %>
      <h3>Purchases (<%= @user.purchases.count %>)</h3>
      <ol class="purchases">
        <%= render @purchases %>
      </ol>
<% end %>
</div>


<div id="sales">

<%= form_for(@sale) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_field :content, placeholder: "Describe something you are interested in selling.", :maxlength=>"254" %>
    <p1> Note: There is a 254 character limit. Be sure to include useful information such as product specifications, price, payment methods accepted, and shipping info (where you live, if you are willing to ship it, ect.). Further detail is best left to email. </p1>
  </div>
  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

<% if @user.sales.any? %>
      <h3>Sales (<%= @user.sales.count %>)</h3>
      <ol class="sales">
        <%= render @sales %>
      </ol>
<% end %>
</div>
  • 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-14T02:53:04+00:00Added an answer on June 14, 2026 at 2:53 am

    The issue was that I needed to define the action of the second form for. I guess by default, the form for assumes that you want the create action. In this case I wanted it to use the update action so I needed to change it to <%= form_for((@purchase), :url => { :action => “update” }) do |f| %>

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

Sidebar

Related Questions

I have a model called Purchase and a model called TicketType. A purchase can
I have a model called User , and another called Run . Each user
I have a model called Event and another called Product. An event has many
I have a model called Invoice .I have made necessary CRUD for Invoice model
I have a model called Business , and I want to save Business.all into
I have a model called Person. I want User to inherit from Person. class
I have a model called Contact which has_one guest like so. class Contact <
I have a model called Answer which has a ForeignKey relationship to another model
I have a model called Details, and two controller methods new and create. New
I have a model called company that has_many users then users belongs_to company. class

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.