Rails3 - why my view loading times are so long? - ruby-on-rails

So one week ago I started to move my old app written in Rails 2.3.5 to new 3.0. Unfortunately, I found out that some of the views are loading surprisingly slow.
Example:
Rails 2.3.5 Ruby 1.8.7 -> WEBrick: Completed in 297ms (View: 143, DB: 40)
Rails 3.0.0 Ruby 1.8.7 -> WEBrick: Completed in 3081ms (View: 261, ActiveRecord: 108)
Rails 3.0.0 Ruby 1.8.7 -> WEBrick: Completed in 2495ms (View: 356, ActiveRecord: 76), slightly improved version -> less SQL queries, more counting in the view
Rails 3.0.0 Ruby 1.9.2 -> WEBrick: Completed in 2941ms (View: 423, ActiveRecord: 90), imp. version
Times differ with every reload of course, but still you can get the idea - in Rails 3 this view loads 10 times slower, no matter if I use Ruby 1.8.7 or 1.9.2. I checked that in development and production environments as well as on Heroku - everytime it looks the same. Other views' loading times are about 2 times slower in 3.0.
Here you can find all the logs:
http://img811.imageshack.us/img811/8514/1rails235ruby187oldver.jpg
http://img217.imageshack.us/img217/5521/2rails300ruby187oldver.jpg
http://img7.imageshack.us/img7/3089/3rails300ruby187diffver.jpg
http://img534.imageshack.us/img534/5138/4rails300ruby192diffver.jpg
What's wrong here? I was busy for 1 week to adapt all my controllers, views, gems, plugins and configs to Rails3 and now I'm stuck... I feel I really should learn some PHP, because it would give me more control on what actually is happening.
The view goes here:
<%= render :partial => 'menu' %>
<div id="preload">
<%= image_tag("/images/next_big.png") %>
</div>
<div class="clearer"><hr /></div>
<div class="picture">
<%= link_to image_tag(#picture.img.url(:page), :alt => #picture.title.gsub("; "," "), :border => 0), :action => "fullsize", :link => #picture.link %>
</div>
<div class="right">
<div class="title"><%= raw #picture.title.gsub("; ","<br />") %></div>
<div class="tags">
<% taglist = #picture.cached_tag_list.split(", ") %>
<% x = taglist.length %>
<% y = 0 %>
<% x.times do %>
<%= taglist[y] %><% y += 1 %><% if y != x %>,<% end %>
<% end %>
</div>
<div class="datetime">Posted <%= time_ago_in_words(#picture.created_at) %> ago</div>
<% this_voting = "voting" %>
<div id="<%= this_voting %>" class="voting">
<%= link_to image_tag("/images/yes.png", :alt => "Vote up", :class => 'vote_button'), {:action => :yes_vote, :id => #picture.id}, :remote => true %>
<span id="<%= this_voting + '_result' %>"><%= #picture.voting %></span>
<%= link_to image_tag("/images/no.png", :alt => "Vote against", :class => 'vote_button'), {:action => :no_vote, :id => #picture.id}, :remote => true %>
Pageviews: <%= #picture.views %>
</div>
<div class="link">Link:<br /><input type="text" value="http://bzzzzzzzzzzz.com/<%= #picture.link %>" /></div>
<div class="share">Share:<br />
<a href="http://facebook.com/sharer.php?u=http://bzzzzzzzzzzz.com/<%= #picture.link %>" target="_blank">
<img src="/images/mfb.png" alt="Facebook" onmouseover="puttext(fb, 0)" onmouseout="cleartext(0)" border="0" /></a>
<a href="http://twitter.com/home?status=http://bzzzzzzzzzzz.com/<%= #picture.link %>" target="_blank">
<img src="/images/mtwitter.png" alt="Twitter" onmouseover="puttext(twitter, 0)" onmouseout="cleartext(0)" border="0" /></a>
<a href="http://digg.com/submit?url=http://bzzzzzzzzzzz.com/<%= #picture.link %>&title=<%= #picture.title.gsub("; "," ") %>&media=image&topic=comedy" target="_blank">
<img src="/images/mdigg.png" alt="Digg" onmouseover="puttext(digg, 0)" onmouseout="cleartext(0)" border="0" /></a>
<a href="http://reddit.com/submit?url=http://bzzzzzzzzzzz.com/<%= #picture.link %>&title=<%= #picture.title.gsub("; "," ") %>" target="_blank">
<img src="/images/mreddit.png" alt="Reddit" onmouseover="puttext(reddit, 0)" onmouseout="cleartext(0)" border="0" /></a>
<a href="http://stumbleupon.com/submit?url=http://bzzzzzzzzzzz.com/<%= #picture.link %>" target="_blank">
<img src="/images/msu.png" alt="StumbleUpon" onmouseover="puttext(su, 0)" onmouseout="cleartext(0)" border="0" /></a>
</div>
<div id="share_caption0" class="share_caption"></div>
<div class="small_clearer"></div>
<% if #picture.last_comment_body %>
<div class="links_to_c">
<%= #picture.comments_count %> comment<% if #picture.comments_count > 1 %>s<% end %>
| <%= link_to "Write a comment", :anchor => "add_comment" %>
</div>
<% else %>
<div class="links_to_c">
<%= link_to "No comments, write a comment", :anchor => "add_comment" %>
</div>
<% end %>
<% if #picture.fullsize == true %>
<div class="fullsize">
<%= link_to "Fullsize", :action => "fullsize", :link => #picture.link %>
</div>
<% end %>
</div>
<div class="next">
<% if #picture.id != 1 %>
<% next_pict_link = Picture.find(#picture.id.to_i - 1).link %>
<%= link_to image_tag("/images/next.png", :alt => 'Next picture', :border=>0, :onmouseover => "this.src='/images/next_big.png'", :onmouseout => "this.src='/images/next.png'"), :action => 'show', :link => next_pict_link %>
<% else %>
<% last_pict_link = Picture.find(:last).link %>
<%= link_to image_tag("/images/next.png", :alt => 'Latest picture', :border=>0, :onmouseover => "this.src='/images/next_big.png'", :onmouseout => "this.src='/images/next.png'"), :action => 'show', :link => last_pict_link %>
<% end %>
</div>
<div class="clearer" style="padding-bottom: 0px"><hr /></div>
<h1><%= #thumbnails_text %></h1>
<% #pictures.each do |pict| %>
<%= link_to image_tag(pict.img.url(:thumb), :alt => "", :border => 1, :class => 'thumbnail'), :action => "show", :link => pict.link %>
<% end %>
<div class="clearer" style="padding-top: 6px; padding-bottom: 15px"><hr /></div>
<% if #picture.last_comment_body != nil %>
<a name="comments"><h1>Comments:</h1></a>
<% #picture.comments.each do |comment| %>
<div id="<%= comment.id %>" class="comment">
<font class="c_author"><%= comment.author %></font>
<font class="c_datetime"><%= time_ago_in_words(comment.created_at) %> ago</font>
<font class="c_id">#<%= comment.id %></font><br />
<div class="c_body"><%= comment.body.gsub(/\n/, '<br />') %></div>
</div>
<% end %>
<% end %>
<div id="insert_here"></div>
<a name="add_comment"></a>
<%= form_for [#picture, Comment.new], :remote => true do |f| %>
<div id="add_comment" <% if #picture.last_comment_body == nil %>style="margin-top: 15px"<% end %>>
<div class="f_section">
<div class="f_type" style="padding-right: 46px"><%= f.label :author, "Nick:" %></div>
<div class="f_field"><%= f.text_field :author, :maxlength => 40 %></div>
</div>
<div class="f_section">
<div class="f_type"><%= f.label :body, "Comment:" %></div>
<div class="f_field"><%= f.text_area :body, :maxlength => 2000, :rows => 6 %></div>
</div>
<div class="f_section">
<div class="f_type" style="padding-right: 20px"><%= f.label :captcha, "Captcha:" %></div>
<div class="f_captcha"><%= raw recaptcha_tags %></div>
</div>
<div class="f_submit">
<%= f.submit "Submit", :class => 'submit' %>
</div>
</div>
<% end %>
<div class="clearer bottom_clearer fifty_from_top"><hr /></div>

There's a lot that can go wrong in any environment, especially PHP.
What could be the issue here is using WEBrick with Rails 3. Using an alternative like mongrel or Passenger could help narrow down this problem.
You could have a situation where something that should be working is timing out, for instance, Memcache is not configured correctly, or a CURL request is being made that eventually fails.
It's always handy to have a very basic view with nothing in it you can use to benchmark the baseline performance of your application. A simple controller with a single action and an empty view can do the trick here. Diagnosing the problem will be a case of adding some of your controller code to this empty action until you can trigger the problem, or stripping parts out of your views to see if that's what causes it.
I usually start commenting out partials to see if one of them is causing the drag, and from there move back to the controller to pay close attention to what's getting loaded.

So.. I think I have tracked down the problem. I saw that WEBrick is giving me back two deprecation warnings (related to RAILS_ROOT and RAILS_ENV). I didnt use any of these phrases by myself, so I started to look for them in my plugins and gems. I found out that they are being used by paperclip (2.3.4) and recaptcha gem (recaptcha by ambethia 0.2.3). Then I removed paperclip from my Gemfile and commented all paperclip related settings from my model. The loading times dropped to 400-500ms.
So I guess I need to wait until somebody will fix paperclip... Im a ruby-newbie, so I wont be able to do this by myself :/

Related

Ruby remote partial being rendered twice

I've spent this afternoon moving code around, trying different things, etc but am unable to solve my (probably simple) problem. I have a button on my index layout that displays a partial form in a modal dialogue to a) create new entries or b) edit existing ones. I'm using the materialize, simple form and client side validation gems.
When I click the button for a new entry the modal appears twice, which looks a bit rubbish but more importantly when I try to save an entry two POST requests are made.
Obviously, I just want the form partial to be rendered once... but I can't work out why its happening twice.
Thanks all for your help, let me know if you need any more than what I have provided below.
This is the button code in the index.html.erb layout
<div class="fixed-action-btn">
<%= link_to "<i class='material-icons'>add</i>".html_safe,
new_patient_path, :remote => true, :id => 'new_patient_link',
:class => "btn-floating btn-large red" %>
</div>
Which then loads the javascript in new.js.erb
$('#modal_partial').html('<%= escape_javascript(render('form')) %>');
That subsequently renders the _form.html.erb partial into the following div (which is stored in a shared/_footer.html.erb partial and sits at the bottom of the index page.
<div id="form_modal_wrap">
<div id="modal_partial" class="modal modal-fixed-footer">
</div>
</div>
And the _form.html.erb partial:
<div id="edit_patient_modal" class="";>
<%= simple_form_for #patient, validate: true, remote: true do |f| %>
<div class="modal-content" style="padding: 0px;">
<h4 class="col s12" style="margin: 0px; padding: 10px 25px;">New Patient</h4>
<%= f.error_notification %>
<div class="row">
<div class="col s12" style="padding: 0px;">
<ul class="tabs" style="padding: 0px;">
<li class="tab col"><a class="active" href="#demographics">Demographics</a></li>
<li class="tab col"><a class="active" href="#admission">Admission</a></li>
<li class="tab col">Presentation</li>
<li class="tab col">Jobs</li>
<li class="tab col">Results</li>
</ul>
</div>
<div id="demographics" class="col s12" style="padding: 20px;">
<%= f.input :nhs, :label => "NHS" %>
<%= f.input :fname, :label => "Firstname" %>
<%= f.input :lname, :label => "Lastname", validate: { presence: true, uniqueness: false } %>
<%= f.input :dob, :label => "DOB", as: :date, start_year: Date.today.year - 110,
end_year: Date.today.year - 12,
order: [:day, :month, :year] %>
<%= f.input :mrn, :label => "MRN" %>
</div>
<div id="admission" class="col s12" style="padding:20px;" >
<%= f.association :location %>
<%= f.input :bed, :label => "Bed" %>
<%= f.association :team, input_html: { multiple: true } %>
</div>
<div id="presentation" class="col s12" style="padding:20px;">
<%= f.input :dx, :label => "Dx" %>
<%= f.input :pmh, :label => "PMH" %>
</div>
<div id="jobs" class="col s12" style="padding:20px">
<p>This job list is shared between all teams.</p>
<%= f.input :jobs, :label => "Jobs" %>
</div>
<div id="results" class="col s12" style="padding:20px;">
<table>
<tr>
<th>Group</th>
<th>Result</th>
<th>Date</th>
</tr>
<% #patient.results.each do |result| %>
<tr>
<td>
<%= Investigation.find(result.investigation_id).group %>
</td>
<td>
<%= Investigation.find(result.investigation_id).short %>
<%= result.value %>
</td>
<td>
<%= result.date %>
</td>
</tr>
<% end %>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<a id="modal_close" href="#!" class="modal-close waves-effect waves-pink btn-flat">Cancel</a>
<%= f.button :submit, :class => "waves-effect btn" %>
</div>
<% end -%>
The following javascript is in the bottom of the _form.html.erb partial:
$(document).ready(function(){
$('#modal_partial .tabs').tabs();
$('#modal_partial select').formSelect();
$('#modal_partial').modal();
$('#modal_partial').modal('open');
$('form').enableClientSideValidations();
});
$("#modal_close").on("click", function(e) {
e.preventDefault();
$('#modal_partial').modal('close');
});
</script>
So I worked out what I'd done in the end...
in application.js I had added both of the following:
//= require jquery_ujs
//= require rails-ujs
By removing either one of these the modals only appeared once. After reading the documentation I only need rails-ujs as it performs the same functions as jquery_ujs, but without having a dependency upon jquery. It does not mean that you can't still have jquery as an independent requirement (as I still do).
So the solution was to delete the line //= require jquery-ujs and just have the following:
//= require rails-ujs
Thanks lacostenycoder for you help
The only way to debug this is to check EVERY part of your code which loads javascript including your layouts. Something is causing the form to duplicate, but it's impossible to debug without seeing all of the code.

Pagination not working only with a certain query

I am using Kaminari gem to paginate using ajax
i have three paginations on the same page
#all_questions = Question.where.not(id: current_user.question_ids).page(params[:unanswered]).per(1)
#wrong = Tracker.where("user_id = ? AND correct = ?", current_user, false).page(params[:wrong_answers]).per(1)
#answered = Tracker.where("user_id = ? AND answered = ?", current_user, true).page(params[:all_answered]).per(1)
while the last two of the above instance variables correctly work. The first one when i click the next button, while i see the ajax request happening in the rails console, it does not refresh the page.
in my view
<%= paginate #all_questions, :remote => true, :param_name => "unanswered" %>
<%= paginate #wrong, :remote => true, :param_name => "wrong_answers" %>
<%= paginate #answered, :remote => true, :param_name => "all_answered" %>
Anyone knows why?
html
<section role="tabpanel" aria-hidden="true" class="content" id="panel2-2">
<div class="row">
<div class="large-10 large-offset-1 columns">
<div class="panel questions-progress-panel">
<ul>
<div id="unanswered">
<%= render partial: "all_questions" %>
</div>
<div id="paginator4" class="text-center paginator">
<%= paginate #all_questions, :remote => true, :param_name => "unanswered" %>
</div>
</ul>
</div>
</div>
</div>
</section>
#all_questions partial
<% #all_questions.each do |q| %>
<li>
<div class="wrapper">
<div class="row">
<div class="large-8 medium-8 small-8 columns">
<p class="question-title"> <%= q.description %> </p>
</div>
<div class="large-4 medium-4 small-4 columns text-right">
<%= link_to "Go", category_question_path(q.category,q), class:"button round success" %>
</div>
</div>
</div>
</li>
<% end %>
Your corresponding js.erb could look like this:
$('#unanswered').html('<%= escape_javascript render(all_questions) %>');
$("#paginator4").html('<%= escape_javascript(paginate(#all_questions, :remote => true).to_s) %>');

Ruby on Rails - dynamic navigation with link_to in a div

I want to add navigation to a series of div, which are loaded dynamically.
For this I am using link to covering the div and passing it the attribute to the method.
The problem is that when I press on the div the attribute does not correspond.
I put the code.
With this code all it's ok, but i don't have the link in the div.
<%for i in inicio..final %>
<div class="col-md-3">
<div class="tarjeta_comercio">
<%= link_to 'mezcla/mostrar_institucion', {:controller => "mezcla", :action => "mostrar_institucion", :institucion_actual => #institucions[azar[i]].id} %>
<div class="foto">
<%= image_tag #institucions[azar[i]].logo.url(:original) %>
</div>
<div class="titulo">
<%= #institucions[azar[i]].nombre %>
</div>
<% end %>
But the problem is when i do a block with "link_to...do-div-end". If i do this the parameter don't run. I don't explain why this happen. This is the wrong code.
<%for i in inicio..final %>
<div class="col-md-3">
<div class="tarjeta_comercio">
<%= link_to 'mezcla/mostrar_institucion', {:controller => "mezcla", :action => "mostrar_institucion", :institucion_actual => #institucions[azar[i]].id} do %>
<div class="foto">
<%= image_tag #institucions[azar[i]].logo.url(:original) %>
</div>
<div class="titulo">
<%= #institucions[azar[i]].nombre %>
</div>
<% end %>
<% end %>
In :institucion_actual each time put 0 (when i pulsed over).
Thanks.

Can't find root of 'stack level too deep' error when rendering partial

I've been stuck on this problem for a week. I will mail you a bottle of scotch if you can figure it out. Seriously, its come to bribery.
On taxons#show I'm rendering a products partial, _products.html.erb, which lists out all the products on a table to the show view of the taxons controller. When you click a product, by default the app will redirect the user to products#show, where the _cart_local.html.erb partial is rendered to display 'add to cart' options.
But on taxons#show, when a product is clicked I bring up a lightbox instead so the user doesn't have to leave the page. The lightbox code is inside _products.html.erb, and I'm trying to render _cart_form.html.erb inside of the lightbox. When I do, I get the 'stack level too deep' error and taxons#show won't render.
But the cart renders fine in products#how. I changed #product in the partial to just product. That didn't help. I rendered an empty partial and the page loads, which makes me think the problem is with _cart_local (but why would it render on products#show?).
Then I took out all of the code in between the opening form tag and the ending div/end tags and the page also rendered, which makes me think its in that block, but I can't wittle it down any further. I'm stuck
Here's the code for _cart_local, and if I take out the code between the <!-- Here --> and <!-- AND HERE --> comments, the page renders:
<%= form_for :order, :url => populate_orders_path do |f| %>
<div id="inside-product-cart-form" data-hook="inside_product_cart_form" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<% if product.has_variants? %> <!-- HERE -->
<div id="product-variants" class="columns five alpha">
<h6 class="product-section-title"><%= t(:variants) %></h6>
<ul>
<% has_checked = false
product.variants.active(current_currency).each_with_index do |v,index|
next if v.option_values.empty? || (!v.in_stock && !Spree::Config[:show_zero_stock_products])
checked = !has_checked && (v.in_stock || Spree::Config[:allow_backorders])
has_checked = true if checked %>
<li>
<%= radio_button_tag "products[#{product.id}]", v.id, checked, :disabled => !v.in_stock && !Spree::Config[:allow_backorders], 'data-price' => v.price_in(current_currency).display_price %>
<label for="<%= ['products', product.id, v.id].join('_') %>">
<span class="variant-description">
<%= variant_options v %>
</span>
<% if variant_price v %>
<span class="price diff"><%= variant_price v %></span>
<% end %>
</label>
</li>
<% end%>
</ul>
</div>
<% end%>
<% if product.price_in(current_currency) and !product.price.nil? %>
<div data-hook="product_price" class="columns five <% if !product.has_variants? %> alpha <% else %> omega <% end %>">
<div id="product-price">
<h6 class="product-section-title"><%= t(:price) %></h6>
<div><span class="price selling" itemprop="price"><%= product.price_in(current_currency).display_price %></span></div>
</div>
<div class="add-to-cart">
<% if product.on_sale? %>
<%= number_field_tag (product.has_variants? ? :quantity : "variants[#{product.master.id}]"),
1, :class => 'title', :in => 1..product.on_hand, :min => 1 %>
<%= button_tag :class => 'large primary', :id => 'add-to-cart-button', :type => :submit do %>
<%= t(:add_to_cart) %>
<% end %>
<% else %>
<%= content_tag('strong', t(:out_of_stock)) %>
<% end %>
</div>
</div>
<% else %>
<div id="product-price">
<br>
<div><span class="price selling" itemprop="price"><%= t('product_not_available_in_this_currency') %></span></div>
</div>
<% end %> <!-- AND HERE -->
</div>
<% end %>
And here is _products.html.erb, the file that is loading all the products, contains the lightbox, and has the render cart partial code:
<div class="overlay-container">
</div>
<%
paginated_products = #searcher.retrieve_products if params.key?(:keywords)
paginated_products ||= products
%>
<% if products.empty? %>
<%= t(:no_products_found) %>
<% elsif params.key?(:keywords) %>
<h6 class="search-results-title"><%= t(:search_results, :keywords => h(params[:keywords])) %></h6>
<% end %>
<div class="product_grid_container">
<div class="grid_2"><%= image_tag("store/featured/#{#featured}.jpg") %></div>
<% if products.any? %>
<ul id="products" class="inline product-listing" data-hook>
<% products.each do |product| %>
<% if product.on_display? %>
<%# ******LIGHTBOX******* %>
<div id="product_popup_<%= product.id %>" class="product_popup" data-popid="<%= product.id %>">
<div class="related-products">
<ul class="related_products_list" id="related_products_list_<%= product.id %>" data-listid="<%= product.id %>">
<% #related_products.each do |related_product| %>
<li class="related_products_item"><%= link_to large_image(related_product, :itemprop => "image", :data => {:imageid => related_product.id}, :id => "related_" + related_product.id.to_s, :class => "related_products_image dimmed"), url_for(related_product) %></li>
<% end %>
</ul>
</div>
<div class="popup-image">
<%= large_image(product, :itemprop => "image", :class => "product-image-popup") %>
</div><!-- popup-image -->
<div class="popup_right_content">
<h2 class="popup-title"><%= product.name %></h2>
<p class="popup-price">$<%= product.price %></p>
<p><%= product.description %></p>
<p class="popup-color">color:</p>
<div class="popup-images" data-productid="<%= product.id %>">
<% if (product.images + product.variant_images).uniq.size > 1 %>
<ul id="popup-thumbnails-taxon" class="thumbnails inline" data-hook>
<% product.images.each do |i| %>
<li class='tmb-all' id='tmb-<%= i.id %>'>
<%= link_to(image_tag(i.attachment.url(:small)), i.attachment.url(:popup), :class => 'tmb-all', :id => "tmb-#{i.id}") %>
</li>
<% end %>
</ul>
<% end %>
</div><!-- popup-images -->
</div><!-- popup_right_content -->
<%= render 'spree/shared/cart_local', :locals => {:product => product} %>
</div><!-- product_popup -->
<%# ******END LIGHTBOX******* %>
<div class="grid_1">
<li id="product_<%= product.id %>" class="columns product three <%= cycle("alpha", "secondary", "", "omega secondary", :name => "classes") %>" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product">
<div class="main-image" id="single_<%= product.id %>" data-productid="<%= product.id %>">
<%= link_to large_image(product, :itemprop => "image", :class => "product-image", :id => product.id), product_path(product), :remote => true, :html => {:class => "product_popup"} %>
</div><!-- main-image-->
<div class="prod_info_box">
<%= link_to truncate(product.name, :length => 50), product, :class => 'info', :itemprop => "name", :title => product.name %>
<span class="price selling" itemprop="price"><%= product.price_in(current_currency).display_price %></span>
<!-- BRINGS THUMBNAILS INTO TAXONS PAGE -- PULLED FROM _THUMBNAILS.HTML.ERB -->
<div class="product-images" data-productid="<%= product.id %>">
<% if (product.images + product.variant_images).uniq.size > 1 %>
<ul id="product-thumbnails-taxon" class="thumbnails inline" data-hook>
<% product.images.each do |i| %>
<li class='tmb-all' id='tmb-<%= i.id %>'>
<%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:normal), :class => 'tmb-all', :id => "tmb-#{i.id}") %>
</li>
<% end %>
</ul>
<% end %>
</div><!-- product-images -->
<!-- END THUMBNAILS INTO TAXONS PAGE -->
<div id="product-description-taxon">
<p><%= product.description %></p>
</div><!-- product-description-taxon -->
</div><!-- prod_info_box -->
</li>
</div>
<% end %>
<% end %>
<% reset_cycle("classes") %>
</ul>
<% end %>
</div><!-- product_grid_container -->
<% if paginated_products.respond_to?(:num_pages) %>
<%= paginate paginated_products %>
<% end %>
Let me know if you need anything else. i appreciate it.
Here's a link to the helpers, maybe the problem is there?
https://github.com/spree/spree/tree/v1.3.2/core/app/helpers/spree
In your _products.html.erb partial change that:
<%= render 'spree/shared/cart_local', :locals => {:product => product} %>
to that:
<%= render partial: 'spree/shared/cart_local', :locals => {:product => product} %>
and problem should be resolved.
Why? Because doing it as you have done it won't pass locals into partial and that's why you've received error, check it by yourself by removing locals. Of course the most interesting part is why you get stack level too deep error here, but I am unable to find answer for that now.
Oh, and debugger is your friend ;)

Rails form submit problem having 2 forms

I have that problem it is always the same form that gets submitted.
The update_limits action gets called on the update order submit button. Which should trigger the action update_order.
Here is my view:
<h2>Movies</h2>
<h3>List movies</h3>
<%= form_tag(:action => 'update_limits' ,:id => params[:id]) %>
<%= link_to 'create new movie', {:action => 'create',:id => params[:id]}, {:class => 'margin-left'} %>
<div class="spacer"> </div>
Number of movies in reel:
<span class="c1">
<% rr = 1..6 %>
<%= select("limits", "reel_limit", rr) %>
</span>
Number of movies in archive:
<span class="c1">
<% rr = 0..12 %>
<%= select("limits", "archive_limit", rr) %>
</span>
<%= submit_tag %>
<div class="spacer"> </div>
<%= form_tag(:controller => 'admin/photographers', :action => 'update_order' ,:id => params[:id]) %>
<ul id='movielist'>
<span class="header">name</span>
<%
n = 0
while n < #items.length
%>
<li itemID='<%=#items[n].id%>' <%= reel_color_class(n, #limits) %>>
<% if #items[n]["image"] %>
<%= image_tag("/photographer/image/#{#items[n].id}/#{#items[n]["image"]}", :size => "36x20" ) %>
<% end %>
<%=#items[n].name.force_encoding("UTF-8") %>
<span class='col2'>
<%= link_to 'edit', {:action => "edit", :id => #items[n].id} %>
<%= link_to("remove", {:action => "remove", :id => #items[n].id },
{:confirm => "Are your sure?"}) %>
</span>
</li>
<%
n = n + 1
end
%>
</ul>
<input type="hidden" name="neworder" id="neworder" value="" />
<input name="commit" type="submit" value="update order" onclick="neworder.value=(junkdrawer.inspectListOrderNew('movielist'))" />
<div class="spacer"> </div>
The form_tag method takes a block, and you are not giving it one. You should be doing something like this:
<%= form_tag(:action => 'update_limits' ,:id => params[:id]) do %>
# form goes here
<% end %>
Or even better, if this is acting on a real object, using a form_for tag:
<%= form_for(#object) do |f| %>
# form_goes here
<% end %>
For more information, please read the Getting Started guide for Rails.

Resources