I have an UploadsController and UsersController where Users'' has_many :uploads'' via polymorphic attachment in uploads.rb. Now we i navigate to http://localhost:3000/users/1/uploads I get re-routed to Uploads#index and rendered is called multiple times as shown below: Started GET "/users/1/uploads" for 127.0.0.1 at 2011-05-06 22:00:38 +0100 Processing by UploadsController#index as HTML Parameters: {"user_id"=>"1"} [1m [35mUser Load (0.0ms) [0m SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 [1m [36mUpload Load (0.0ms) [0m [1mSELECT "uploads".* FROM "uploads" [0m Rendered uploads/_upload.html.erb (0.0ms) Rendered uploads/_upload.html.erb (0.0ms) Rendered uploads/_upload.html.erb (0.0ms) Rendered uploads/index.html.erb within layouts/application This my config/routes Uploader::Application.routes.draw do devise_for :users resources :users do resources :uploads end root :to => ''users#index'' ##class UsersController < ApplicationController def show @user = User.find end #views/users/show.html.erb <div> <% @user.email %> <h3 id="photos_count"><%= pluralize(@user.uploads.size, "Photo")%></ h3> <div id="uploads"> <%= image_tag @user.uploads.url(:small)%> <em>on <%= @user.upload.created_at.strftime(''%b %d, %Y at %H:%M'') %></ em> </div> <h3>Upload a Photo</h3> <%= render "upload/form", :parent => @user, :upload => user.uploads.new %> ##class UploadsController < ApplicationController def index @uploads = Upload.all @upload = Upload.new end ##def show @upload = @parent.uploads.find(params[:id]) @total_uploads = @parent.uploads.find(:all, :conditions => { :user_id => @upload.user.id}) end #views/uploads/index.html.erb <% unless @uploads.blank? %> <% @uploads.each do |upload| %> <%= render :partial => ''upload'', :locals => {:collection => @upload.try(:document)} %> <% end %> <% end %> <div id="uploads"> <h3>Upload a document</h3> <%= render ''form'', :parent => @parent, :upload => @upload.new % </div> Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
How many Uploads does the User with the ID=1 have? I believe it''s three, and that each upload get''s rendered. Can you show us the view for the uploads index? On Samstag, 7. Mai 2011 at 00:14, brg wrote: I have an UploadsController and UsersController where Users''> has_many :uploads'' via polymorphic attachment in uploads.rb. > > Now we i navigate to http://localhost:3000/users/1/uploads > > I get re-routed to Uploads#index and rendered is called multiple times > as shown below: > > Started GET "/users/1/uploads" for 127.0.0.1 at 2011-05-06 22:00:38 > +0100 > Processing by UploadsController#index as HTML > Parameters: {"user_id"=>"1"} > [1m [35mUser Load (0.0ms) [0m SELECT "users".* FROM "users" WHERE > "users"."id" = 1 LIMIT 1 > [1m [36mUpload Load (0.0ms) [0m [1mSELECT "uploads".* FROM > "uploads" [0m > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/index.html.erb within layouts/application > > This my config/routes > Uploader::Application.routes.draw do > devise_for :users > resources :users do > resources :uploads > end > root :to => ''users#index'' > > ##class UsersController < ApplicationController > def show > @user = User.find > end > > #views/users/show.html.erb > <div> > <% @user.email %> > <h3 id="photos_count"><%= pluralize(@user.uploads.size, "Photo")%></ > h3> > <div id="uploads"> > <%= image_tag @user.uploads.url(:small)%> > <em>on <%= @user.upload.created_at.strftime(''%b %d, %Y at %H:%M'') %></ > em> > </div> > <h3>Upload a Photo</h3> > <%= render "upload/form", :parent => @user, :upload => > user.uploads.new %> > > ##class UploadsController < ApplicationController > def index > @uploads = Upload.all > @upload = Upload.new > end > > ##def show > @upload = @parent.uploads.find(params[:id]) > @total_uploads = @parent.uploads.find(:all, :conditions => > { :user_id => @upload.user.id}) > end > > #views/uploads/index.html.erb > <% unless @uploads.blank? %> > <% @uploads.each do |upload| %> > <%= render :partial => ''upload'', :locals => {:collection => > @upload.try(:document)} %> > <% end %> > <% end %> > <div id="uploads"> > <h3>Upload a document</h3> > <%= render ''form'', :parent => @parent, :upload => @upload.new % > </div> > > Thanks > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
@Jens thanks. All users have many uploads. This is views/uploads/ index.html.erb <% unless @uploads.blank? %> <% @uploads.each do |upload| %> <%= render :partial => ''upload'', :locals => {:collection => @upload.try(:document)} %> <% end %> <% end %> </br> <%= render ''form'', :parent => @parent, :upload => @upload %> On May 7, 11:43 am, Jens Fahnenbruck <jig...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> How many Uploads does the User with the ID=1 have? I believe it''s three, and that each upload get''s rendered. > > Can you show us the view for the uploads index? > On Samstag, 7. Mai 2011 at 00:14, brg wrote: > I have an UploadsController and UsersController where Users'' > > > > > > > > > has_many :uploads'' via polymorphic attachment in uploads.rb. > > > Now we i navigate tohttp://localhost:3000/users/1/uploads > > > I get re-routed to Uploads#index and rendered is called multiple times > > as shown below: > > > Started GET "/users/1/uploads" for 127.0.0.1 at 2011-05-06 22:00:38 > > +0100 > > Processing by UploadsController#index as HTML > > Parameters: {"user_id"=>"1"} > > [1m [35mUser Load (0.0ms) [0m SELECT "users".* FROM "users" WHERE > > "users"."id" = 1 LIMIT 1 > > [1m [36mUpload Load (0.0ms) [0m [1mSELECT "uploads".* FROM > > "uploads" [0m > > Rendered uploads/_upload.html.erb (0.0ms) > > Rendered uploads/_upload.html.erb (0.0ms) > > Rendered uploads/_upload.html.erb (0.0ms) > > Rendered uploads/index.html.erb within layouts/application > > > This my config/routes > > Uploader::Application.routes.draw do > > devise_for :users > > resources :users do > > resources :uploads > > end > > root :to => ''users#index'' > > > ##class UsersController < ApplicationController > > def show > > @user = User.find > > end > > > #views/users/show.html.erb > > <div> > > <% @user.email %> > > <h3 id="photos_count"><%= pluralize(@user.uploads.size, "Photo")%></ > > h3> > > <div id="uploads"> > > <%= image_tag @user.uploads.url(:small)%> > > <em>on <%= @user.upload.created_at.strftime(''%b %d, %Y at %H:%M'') %></ > > em> > > </div> > > <h3>Upload a Photo</h3> > > <%= render "upload/form", :parent => @user, :upload => > > user.uploads.new %> > > > ##class UploadsController < ApplicationController > > def index > > @uploads = Upload.all > > @upload = Upload.new > > end > > > ##def show > > @upload = @parent.uploads.find(params[:id]) > > @total_uploads = @parent.uploads.find(:all, :conditions => > > { :user_id => @upload.user.id}) > > end > > > #views/uploads/index.html.erb > > <% unless @uploads.blank? %> > > <% @uploads.each do |upload| %> > > <%= render :partial => ''upload'', :locals => {:collection => > > @upload.try(:document)} %> > > <% end %> > > <% end %> > > <div id="uploads"> > > <h3>Upload a document</h3> > > <%= render ''form'', :parent => @parent, :upload => @upload.new % > > </div> > > > Thanks > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 May 2011, at 23:14, brg <bauchiroad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have an UploadsController and UsersController where Users'' > has_many :uploads'' via polymorphic attachment in uploads.rb. > > Now we i navigate to http://localhost:3000/users/1/uploads >That''s normal, but you do need to only fetch the uploads for the user in question. (params[:user_id] should be set) Fred> I get re-routed to Uploads#index and rendered is called multiple times > as shown below: > > Started GET "/users/1/uploads" for 127.0.0.1 at 2011-05-06 22:00:38 > +0100 > Processing by UploadsController#index as HTML > Parameters: {"user_id"=>"1"} > [1m [35mUser Load (0.0ms) [0m SELECT "users".* FROM "users" WHERE > "users"."id" = 1 LIMIT 1 > [1m [36mUpload Load (0.0ms) [0m [1mSELECT "uploads".* FROM > "uploads" [0m > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/_upload.html.erb (0.0ms) > Rendered uploads/index.html.erb within layouts/application > > This my config/routes > Uploader::Application.routes.draw do > devise_for :users > resources :users do > resources :uploads > end > root :to => ''users#index'' > > ##class UsersController < ApplicationController > def show > @user = User.find > end > > #views/users/show.html.erb > <div> > <% @user.email %> > <h3 id="photos_count"><%= pluralize(@user.uploads.size, "Photo")%></ > h3> > <div id="uploads"> > <%= image_tag @user.uploads.url(:small)%> > <em>on <%= @user.upload.created_at.strftime(''%b %d, %Y at %H:%M'') %></ > em> > </div> > <h3>Upload a Photo</h3> > <%= render "upload/form", :parent => @user, :upload => > user.uploads.new %> > > ##class UploadsController < ApplicationController > def index > @uploads = Upload.all > @upload = Upload.new > end > > ##def show > @upload = @parent.uploads.find(params[:id]) > @total_uploads = @parent.uploads.find(:all, :conditions => > { :user_id => @upload.user.id}) > end > > #views/uploads/index.html.erb > <% unless @uploads.blank? %> > <% @uploads.each do |upload| %> > <%= render :partial => ''upload'', :locals => {:collection => > @upload.try(:document)} %> > <% end %> > <% end %> > <div id="uploads"> > <h3>Upload a document</h3> > <%= render ''form'', :parent => @parent, :upload => @upload.new % > </div> > > Thanks > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Seemingly Similar Threads
- No return status from mongrel upload progress (and thus no updates on the bar)
- Can't get to an action in a RESTful controller
- Devise confusing routes
- Cucumber+Capybara rails 3 issue (Don't know where exactly)
- Authlogic Password confirmation is too short Error. NEED HELP.