[Rails] render partial in json resonse

2018-05-13 Thread fugee ohu
error:
ActionView::Template::Error (Missing partial transactions/_receipt, 
application/_receipt with {:locale=>[:en], :formats=>[:js, :html, :text, 
:css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :xml, 
:rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, 
:gzip], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, 
:coffee, :jbuilder]}. Searched in:

the create action in transactions_controller.rb:
...
if @transaction.save
format.json { render partial: 'receipt', status: :created, 
location: @parlor }
...
create.js.erb:
$('#drop_in_container').html('<%= j render partial: 'receipt', locals: 
@transaction %>')

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/c8aa93fa-f0be-4262-8caa-45d71f1a8568%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Help regarding a problem

2018-05-13 Thread Geetha Reddy
 

Hi All, I have the following problem. can you help me in solving this.

Suppose we could access yesterday's stock prices as an array where:

 

- The indices are the time in minutes past trade opening time, which was 
9:30 am local time

- The values are the price in dollars of Apple stock at that time

 

So if the stock cost $500 at 10:30am, stock_prices_yesterday[60] = 500

 

Write an efficient function that takes stock_prices_yesterday and returns 
the best profit I could have made 1 purchase and 1 sale of 1 Apple stock 
yesterday.

 

Below is a solution that uses brute force algorithm. Big 0(n2). Can you 
write an improved solution at Big 0(n2) or even better Big 0(n)

 

*def get_max_profit(stock_prices_yesterday)*

 

*  max_profit = 0*

 

*# go through every time*

*for outer_time in (0...stock_prices_yesterday.length)*

 

*# for every time, go through every OTHER time*

*for inner_time in (0...stock_prices_yesterday.length)*

 

*# for each pair, find the earlier and later times*

*earlier_time = [outer_time, inner_time].min*

*later_time   = [outer_time, inner_time].max*

 

*# and use those to find the earlier and later prices*

*erlier_price = stock_prices_yesterday[earlier_time]*

*later_price  = stock_prices_yesterday[later_time]*

 

*# see what our profit would be if we bought at the*

*# earlier price and sold at the later price*

*potential_profit = later_price - earlier_price*

 

*# update max_profit if we can do better*

*max_profit = [max_profit, potential_profit].max*

*end*

*end*

*return max_profit*

*end*

 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d6829f20-3d19-471b-8910-7ac1700c1820%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] How do I override asset_path while retaining access to the original?

2018-05-13 Thread Todd Blanchard
I've been banging my head on this for some days.

I am working on a multi-tenant rails application that wants to use themes 
for each tenant.

I have managed to customize view template finding with FileSystemResolver 
so that it prepends the current domain to the view search path and, if not 
found, removes it and uses the original one.  This works.

Assets, OTOH, have me stumped.  As near as I can figure, everything goes 
through ActionView::Helpers::AssetUrlHelper.asset_path(source,options). 
 That mostly does what I want but I want to prepend the domain to the 
source path.  

To make things extra fun, half the assets/views are in a gem (using Solidus 
as our store) and so a lot of my controllers are straight out of the 
Solidus engine.

I could really use some guidance on getting this working.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5da9e5be-439c-489a-9488-f0124844d09e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.