Ruby on Rails Monday, November 30, 2015

Hello,  It turns out that our Apps Variant relation model + ActiveRecord Relations produces some very funky behaviour which was preventing it from being used in .includes preloads.    Background: Our App's variant model has a boolean column(composite) and they reflect back on themselves through a subsidiary table  (composites). A Composite entry may reference a variant as a variant_id which has many other composite variants which reference the former by parent_id. e.g.
Variants
id
: 1
name
: SnackBox
composite
: true

id
: 2
name
: Snickers
composite
: false

id
: 3
name
: Bounty
composite
: false

Composites
id
: 1 # references SnackBox
parent_id
: null # is a parent
variant_id
: 1

id
: 2 #references snickers a composite of SnackBox
parent_id
: 1
variant_id
: 2

id
: 3 #references bounty a composite of SnackBox
parent_id
: 1
variant_id
: 3

Here is the original code we used in the App to achieve loading this relation:    
class Variant < ActiveRecord::Base
 has_many
:composites, foreign_key: :parent_id, dependent: :destroy
 has_many
:composite_variants_singular, -> { select "variants.*, composites.quantity as composite_quantity" },
 through
: :composites, source: :variant
end

Here is what happens when you run the composite_variants on a single variant.
Variant Load (0.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."id" = $1 LIMIT 1 [["id", <ID>]]


And alternatively in an includes (notice that SELECT variants.* will fail in the later):
Variant Load (0.7ms) SELECT variants.*, composites.quantity as composite_quantity FROM "variants"
INNER JOIN
"composites" ON "variants"."id" = "composites"."variant_id" WHERE "composites"."parent_id" = $1 [["parent_id", <ID>]]
Here is the alternative code path I attempted:
has_many :composite_variants_joined, -> {
 joins
('''INNER JOIN "composites" ON "composites".variant_id = "variants".id''')
 
.select "variants.*, composites.quantity as composite_quantity"
},
through
: :composites, source: :variant

The alternative query generated looks like this (which works correctly for includes):
Variant Load (89.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."account_id" = $1 [["account_id", <ID>]]
Composite Load (53.6ms) SELECT "composites".* FROM "composites" WHERE "composites"."parent_id" IN (<ARRAY>)
Variant Load (3.0ms) SELECT variants.*, composites.quantity as composite_quantity FROM "variants" INNER JOIN "composites" ON "composites".variant_id = "variants".id WHERE "variants"."id" IN (<ARRAY>)

But breaks tremendously on the single instance load.
Variant Load (0.4ms) SELECT "variants".* FROM "variants" WHERE "variants"."id" = $1 LIMIT 1 [["id", <ID>]]
PG
::DuplicateAlias: ERROR: table name "composites" specified more than once
: SELECT variants.*, composites.quantity as composite_quantity FROM "variants" INNER JOIN "composites" ON "variants"."id" = "composites"."variant_id" INNER JOIN "composites" ON "composites".variant_id = "variants".id WHERE "composites"."parent_id" = $1

The final solution I ended up with looked like this:
class Variant < ActiveRecord::Base
 has_many
:composites, foreign_key: :parent_id, dependent: :destroy
 has_many
:parent_composites, class_name: "Composite"
 has_many
:composite_variants, ->(variant) { _composite_variants(variant) },
 through
: :composites, source: :variant

 
def self.with_composite_quantity
 
self.select("variants.*, composites.quantity as composite_quantity")
 
end
 
# This is a work-around to allow fetching composite variants for an single variant instance
 
# as well pre-loading of of composite_variants via .includes - Since AR does not support a single
 
# method for doing so we determine which method to use based on whether the lambda has a variant
 
# instance passed in as an argument.
 
def self._composite_variants(variant)
 
if variant
   with_composite_quantity
 
else
   
self.joins(:parent_composites).with_composite_quantity
 
end
 
end
end

While I don't expect ActiveRecord Relations to handle every single use case - the clearly incorrect SQL (duplicating the same INNER JOIN clause twice) on the .includes() and the complexity of the final solution is quite suspect, so I was hoping to have an outside opinion. Thanks for your time. Alex

P.S. Sorry about the formatting the Google UI is wrapping all my attempts to format code-blocks into single lines without the quotes. 

--
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+unsubscribe@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/03851141-8e03-42c5-b46a-f504cbe18283%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

this snippet which follows another code block under       $(document).ready(function () {    isn't working, the previous block works, but not this one

  $('#listing_free_shipping').change(function(e)
   {
    if (e.listing_free_shipping.attr('checked'))
     {
     $("#listing_shipping_cost").toggle( "blind" );
     }
    else
     {
     $("#listing_shipping_cost").show();
     }
  })

--
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+unsubscribe@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/b61f22f6-cd32-4dd7-9f53-e4eaf637a523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello folks,

Team Codemancers is proud to release Invoker version 1.4.1. If you haven't used Invoker before, checkout http://invoker.codemancers.com/ for more information.

This new version packs bunch of goodies and fixes. A brief list is as follows:

1. Invoker supports processes that are inactive by default but can be started
   via invoker add. More information - https://github.com/code-mancers/invoker/pull/114

2. Invoker now supports a global config file defined in ~/.invoker directory which can be
   used from anywhere.

3. Added support for Debian, Mint and Arch Linux.

4. When starting invoker one can specify the beginning port. More details:

5. Added bash completion for Invoker - https://github.com/code-mancers/invoker/pull/148

6. when running invoker list, also show port number - https://github.com/code-mancers/invoker/pull/149

7. Invoker now supports different subdomains to be directed to different applications.
   For example: foo.dev can direct to web application whereas chat.foo.dev can direct to
   another application. More details - https://github.com/code-mancers/invoker/pull/129



If you have any feedback or comments, please let us know.



--

--
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+unsubscribe@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/CABQG7ZtCfq9dqE%3DjSiPasfjtN%3D%3DFE9bAGRcevVb2hhxKxjC8sA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 November 2015 at 21:22, Colin Law <clanlaw@gmail.com> wrote:
> On 30 November 2015 at 19:26, Yash Narwal <ynarwal10@gmail.com> wrote:
>> Hey mate thanks for heads up, your suggestion worked in installing the gem.
>> But how can I use this gem now, like if I follow this example , it gives me
>> no such file can not be loaded 'numru/grib'. So is there any other docs
>> which should I follow to use this gem ?
>
> I have no idea, I have not heard of it before you asked, I just
> googled a bit to come up with my previous suggestion. However if you
> tell us more someone may be able to help. Post the source file around
> the area giving the error and post the full error message and tell us
> which line it is failing on.

On second thoughts I assume you are getting the error on the line
require 'numru/grib'. Is this in a Ruby on Rails app or in a straight
ruby script?

Colin

--
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+unsubscribe@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/CAL%3D0gLsdBjcfL0AVTyAEs9mJWHnao5RbCsch9K5oiXv%3DADXyMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 November 2015 at 19:26, Yash Narwal <ynarwal10@gmail.com> wrote:
> Hey mate thanks for heads up, your suggestion worked in installing the gem.
> But how can I use this gem now, like if I follow this example , it gives me
> no such file can not be loaded 'numru/grib'. So is there any other docs
> which should I follow to use this gem ?

I have no idea, I have not heard of it before you asked, I just
googled a bit to come up with my previous suggestion. However if you
tell us more someone may be able to help. Post the source file around
the area giving the error and post the full error message and tell us
which line it is failing on.

Colin

>
> I really appreciate your help.
>
> Thanks
> Yash
>
> On Sunday, November 29, 2015 at 8:28:05 PM UTC+11, Colin Law wrote:
>>
>> On 29 November 2015 at 08:33, Yash Narwal <ynar...@gmail.com> wrote:
>>>
>>> HI there , I am trying to install a ruby gem called rb-grib but I am
>>> constantly having issues while doing so.
>>> I am using Ubuntu 15.04
>>>
>>> So I went to this page http://www.rubydoc.info/gems/rb-grib/0.2.2
>>> I tried to install requirements for this gem which are
>>>
>>> Ruby (www.ruby-lang.org/) Pass
>>> NArray (narray.rubyforge.org/index.html.en) Pass
>>> NArrayMiss (ruby.gfd-dennou.org/products/narray_miss/) Pass
>>> GRIB API (www.ecmwf.int/products/data/software/grib_api.html) Fail
>>>
>>> In order to install grib_api I followed every instructions I can find on
>>> web but when it comes to final step in installation (sudo make install) , it
>>> gives me an error
>>> "checking for grib_api.h ... no"
>>> "Could not create makefile due to some reason"
>>>
>>> I have followed this guide to install grib api Guide
>>> Snapshot of the error I am having in the final command for the api(from
>>> the guide link) (make install)
>>> I am really look forward to have some help in installing the rb-grib gem.
>>
>>
>> sudo apt-get install ruby-grib
>> might be what you want. The description is "Ruby interface to the ECMWF
>> GRIB API
>> It is always worth using synaptic to search the repositories before trying
>> to install by hand.
>>
>> Colin
>>
>
> --
> 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+unsubscribe@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/f5c737b3-563e-4d20-93b9-b5f3fbdd997c%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAL%3D0gLt89suFvKXMeEHNCrJp1%3D6-TxTOqoq_oKV-mpt8oqUDtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hey mate thanks for heads up, your suggestion worked in installing the gem. But how can I use this gem now, like if I follow this example , it gives me no such file can not be loaded 'numru/grib'. So is there any other docs which should I follow to use this gem ?

I really appreciate your help.

Thanks
Yash

On Sunday, November 29, 2015 at 8:28:05 PM UTC+11, Colin Law wrote:
On 29 November 2015 at 08:33, Yash Narwal <ynar...@gmail.com> wrote:
HI there , I am trying to install a ruby gem called rb-grib but I am constantly having issues while doing so.
I am using Ubuntu 15.04

I tried to install requirements for this gem which are 
In order to install grib_api I followed every instructions I can find on web but when it comes to final step in installation (sudo make install) , it gives me an error
"checking for grib_api.h ... no"
"Could not create makefile due to some reason"

I have followed this guide to install grib api Guide
Snapshot of the error I am having in the final command for the api(from the guide link) (make install)
I am really look forward to have some help in installing the rb-grib gem.

sudo apt-get install ruby-grib
might be what you want.  The description is "Ruby interface to the ECMWF GRIB API
It is always worth using synaptic to search the repositories before trying to install by hand.

Colin
 

--
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+unsubscribe@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/f5c737b3-563e-4d20-93b9-b5f3fbdd997c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

<script>
$(document).ready(function () {
  $('#listing_format').change(function(e)
   {
    if (e.target.value=('Fixed price') {$("#listing_starting_bid").toggle( "blind" ); }
  })
})
</script>

<%= form_for(@listing) do |f| %>
  <% if @listing.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@listing.errors.count, "error") %> prohibited this listing from being saved:</h2>

etc ...

I want the document above to apply the blind effect to the starting bid field but nothing changes in the browser


--
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+unsubscribe@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/29b6fc16-0d5e-42d9-af43-5416c433556c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 November 2015 at 13:19, Alexis Cretton <lists@ruby-forum.com> wrote:
> Hello,
>
> I've been trying to install and update different gems to work with Ruby
> on Rails, but keep getting the same error, apparently indicating I can't
> install or update any gem:
>
> I generally type in something like:
>
> gem update --system or gem install Rails --version 4.0.0 --no-ri
> --no-rdoc
>
> And get the following:
>
> ERROR: While executing gem ... (Errno::EINVAL)
> Invalid Argument - socket(2) - udp
>
> Note that I've proceeded to the same setup just a couple of days before
> on a different machine and had no problem.

Are you running the same version of Ruby on both setups, and which version is it
ruby -v
will tell you.

You may well have difficulties getting help with a Windows setup
however, as few Rails developers use Win.

Colin

--
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+unsubscribe@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/CAL%3D0gLsJDHzG8hyVBD9dEhFK-5u-NuBe9-rgA4Npo5OWXtR81A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails


On Sunday, November 29, 2015 at 4:09:04 PM UTC, dave wrote:
Fred
 
Hi Fred,
Thank you for your response and explanation: development vs production javascript tags. Yes I also set traces into sprockets and manifest.rb code before my original post.
Where the tracing falls down is in the eval statement which switches into another run context and so Byebug is left hanging.
Maybe this is a Byebug forum question? or possibly i'm pushing its run-context envelope past its original design?


Given that the eval calls Rack::Builder.new I would set a breakpoint on  Rack::Builder.initialize. I don't think you need any tools beyond bye bug for this sort of thing. However, this won't lead you directly to where javascript gets generated because that is done on demand, not at app startup. You'd want a breakpoint at the top of the rack middleware if you wanted to trace what happens when a js file is requested.

Fred
 

--
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+unsubscribe@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/0917c395-c7d6-49e5-bd30-1e775f22908c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello,

I've been trying to install and update different gems to work with Ruby
on Rails, but keep getting the same error, apparently indicating I can't
install or update any gem:

I generally type in something like:

gem update --system or gem install Rails --version 4.0.0 --no-ri
--no-rdoc

And get the following:

ERROR: While executing gem ... (Errno::EINVAL)
Invalid Argument - socket(2) - udp

Note that I've proceeded to the same setup just a couple of days before
on a different machine and had no problem.

I couldn't figure any place where this same Error was explained or
encoutered.

Anybody here can help out?

--
Posted via http://www.ruby-forum.com/.

--
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+unsubscribe@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/46b502f97c68c73f6d8eea0952061997%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Several years ago, I had a similar desire to have a screen representation of a category tree.  I was very surprised that I couldn't find any pre-baked solution, so I built my own (there may be one out there now of which I am unaware).  Unfortunately, I have never got round to making my code public, but I can share some of the design considerations I had to consider.

1.  What sort of tree would I like - I went for creating something along the lines of the windows file explorer - a pretty standard representation.
2.  What elements would this require:
a.  Database - a category structure - ie.  Awesome nested set worked well for me.
b.  Visual - simple graphics, small images for: node open, node closed, leaf
c.  Next step was to build  a simple mock up on the screen to create the CSS for the tree structure.  HTML struture would be nested ul lists for branches and li elements for nodes and leafs.  classes for the open and closed state.  (I could share this if you like)

2.  Perhaps the most difficult question is the decision of how much I am going to do in JS and how much server side.  I considered supplying the whole tree in json format and then using js to build the visual and keep things in step.  But it just seemed to get too involved.  And took me more into js development than I was comfortable with.

3.  The solution I used was to maintain the tree on the server, and open close, create and delete nodes using ajax calls.  Rewriting sections of the tree by replacing nodes by rendering appropriate partials.

4.  Giving each node an id of the category model object id allows the server to manage the tree by js responses that show/hide branches.

5.  It can seem a bit of a daunting task, but if you break it down into the steps above, create open/closed partials that call each other, then build the ajax calls for open/close,  it is actually not that hard, and I have a working solution that is common across three projects. Rails 2 and Rails 4. 


Hopefully this at least gives some food for thought.
Tony



On Monday, 23 November 2015 21:13:57 UTC, Colin Law wrote:
On 23 November 2015 at 21:11, fugee ohu <fuge...@gmail.com> wrote:
> how to format them on a page ... my thought was to use group_by for
> formatting a page that displays all categories

Do the tutorial.

Colin

>
> On Monday, November 23, 2015 at 3:39:05 PM UTC-5, Colin Law wrote:
>>
>> On 23 November 2015 at 20:11, fugee ohu <fuge...@gmail.com> wrote:
>> > I'm looking for a solution for managing categories My categories table
>> > has
>> > name , parent_id fields My first challenge is to display all categories
>> > on a
>> > single page and my next is to build select lists represenative of the
>> > tree
>> > (after this has been done I wanna  integrate listings with them)
>>
>> I don't understand what is challenging about your first challenge.  Do
>> you mean you don't know how to get the categories from the database
>> (Category.all) or how to format them on a page or what?
>>
>> It suggests to me that you have still not followed my and Tamara's
>> advice to work right through railstutorial.org.  Until you understand
>> the basics you are just wasting your time and ours.
>>
>> Colin
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/145b7f8d-6956-44b3-ac9a-57fecd95e33e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/384f64e3-ae98-4ce7-a9d7-b1bda61ec04e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, November 29, 2015

i wanna use jquery to render an element identified in the view by <div id="element"> The view is _form.html.erb called by new.html.erb So I have to create a jquery controller with an action to print content through a partial to be sent to replace the element in the form My call to jquery is in the form contained in <script> tags I dunno if I was supposed to use the script tags since I'm using jquery, not javascript raw and then what action would go in the controller Is it the new action? From my form:

<script>
$(#element).on('change', 'a_select_list', function (e) {
  if ($(this).val() == 'a_select_list_option'){
  render 'partial_to_replace_contents_of_element'
  }
});
</script>


--
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+unsubscribe@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/b290aaa3-1b97-42a8-87ed-f5b4806d87bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, November 28, 2015 at 4:09:08 PM UTC-5, Colin Law wrote:

On 28 November 2015 at 19:38, dave <bone_...@mac.com> wrote:
> Hi Group,
> I'm trying to see how Rails at ``startup time'' creates  Javascripts within
> the Clientside of the browser.
>
>      rails s #starting my program
>
> I've used both Byebug within Ruby code and Firefoxe's debugger within the
> browser.
> ==> Firefox's debug shows me the generated scripts like jquery etc but this
> is after the fact: the code producing the scripts has already executed.
>        I want to observe how/when it generates the script and how various
> callbacks are registered particularly in jquery. Eg plot function using
> flot.

All rails does is to package up the js from the relevant gems serve it
on to the browser.  If you look in the flot gem you will see
effectively the same javascript that you see in the Firefox debugger.

Hi Colin,
Thk u for the reply. Yes i'm aware of this behaviour.
What i'm trying to understand is the Ruby code used to do it. As just posted to Fred, for me it now becomes a debugger issue to continue observing the code pattern for the javascript presented to the Browser.
Any suggestions to debugging the Eval statement in continued tracing code sequencing is appreciated.
Dave 

Colin

--
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+unsubscribe@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/498c0b8f-df4b-4097-859d-949e331428e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, November 28, 2015 at 3:55:25 PM UTC-5, Frederick Cheung wrote:

On Saturday, November 28, 2015 at 7:38:17 PM UTC, dave wrote:
> Hi Group,
> I'm trying to see how Rails at ``startup time'' creates  Javascripts within the Clientside of the browser.
>
>      rails s #starting my program
>
> I've used both Byebug within Ruby code and Firefoxe's debugger within the browser.
> ==> Firefox's debug shows me the generated scripts like jquery etc but this is after the fact: the code producing the scripts has already executed.
>        I want to observe how/when it generates the script and how various callbacks are registered particularly in jquery. Eg plot function using flot.

sprockets turns manifests like application.js into a single JavaScript file. In development mode typically this doesn't happen - rails turns the call to javascript_include_tag into script tags that load all of the files specified by application.js. What happens next is entirely in the browser.

Rails doesn't execute any JavaScript (unless you count the compilation of coffeescript, transpiling via the Babel gem etc. This also goes via sprockets)


Fred
 
Hi Fred,
Thank you for your response and explanation: development vs production javascript tags. Yes I also set traces into sprockets and manifest.rb code before my original post.
Where the tracing falls down is in the eval statement which switches into another run context and so Byebug is left hanging.
Maybe this is a Byebug forum question? or possibly i'm pushing its run-context envelope past its original design?

By having Byebug trace Ruby lines allows me to investigate the other Ruby code used to generate the javascripts for the browser. 
Do u know of any debugging facilities to continue these investigations? Or should i look at Dtrace?
My thoughts are that the Core Rails developers are faced with the same problem and have appropriate tools to set break points,and output line traces.
Any suggests appreciated
Dave
>
> ==> Byebug stops when the Ruby code does an eval expression when tracing from config/application.rb :
> I used byebug's  set linetrace to observe the following:
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:33       options = {}
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:34       if config =~ /\.ru$/
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:35         cfgfile = ::File.read(config)
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:36         if cfgfile[/^#\\(.*)/] && opts
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:39         cfgfile.sub!(/^__END__\n.*\Z/m, '')
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40         app = new_from_string cfgfile, config
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49       eval "Rack::Builder.new {\n" + builder_script + "\n}.to_app",
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49       eval "Rack::Builder.new {\n" + builder_script + "\n}.to_app",
>
> where the eval statement just sits and waits. At that point I had to abort the program at startup using Cntl C
>
> My questions so far are:
>    1) how to trace  outside programs  called by Ruby like Rack::Builder'' above to continue my investigations. Other more powerfull debug tracers to use? DTRACE?
>       1.5) Can break points be placed against the source code before the dynamic tracing begins? or have a pre-programmed script set the breakpoints at runtime?
>
>    2) how is javascript executed by ``Ruby start up''  to manufacture the local registered scripts: ie, the various crossovers between Ruby and Javascript contexts
>
> Any pointers to documents/websites/forums where these questions allow me to continue my investigations is appreciated
>
> I thank you in advance for your ``eyes and ears'' evaluating my request
> Dave

--
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+unsubscribe@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/2ae027cb-5839-428e-92d1-593c7a1c2162%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello Friends,

https://www.youtube.com/watch?v=dfViQPZw9zE - see quick demo to see
example of using powerful filters in Rails DB. Multiple conditions,
sorting added.

Gem: https://github.com/igorkasyanchuk/rails_db

Please check and thank you for feedback

--
Posted via http://www.ruby-forum.com/.

--
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+unsubscribe@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/7e26336bccf00daa32f9a10d31ba22dd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 November 2015 at 08:33, Yash Narwal <ynarwal10@gmail.com> wrote:
HI there , I am trying to install a ruby gem called rb-grib but I am constantly having issues while doing so.
I am using Ubuntu 15.04

I tried to install requirements for this gem which are 
In order to install grib_api I followed every instructions I can find on web but when it comes to final step in installation (sudo make install) , it gives me an error
"checking for grib_api.h ... no"
"Could not create makefile due to some reason"

I have followed this guide to install grib api Guide
Snapshot of the error I am having in the final command for the api(from the guide link) (make install)
I am really look forward to have some help in installing the rb-grib gem.

sudo apt-get install ruby-grib
might be what you want.  The description is "Ruby interface to the ECMWF GRIB API
It is always worth using synaptic to search the repositories before trying to install by hand.

Colin
 

--
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+unsubscribe@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/CAL%3D0gLv9njJL4FAggjHufzP9jiww9%2B59UmH2cAQa0ZRw4xpjAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

HI there , I am trying to install a ruby gem called rb-grib but I am constantly having issues while doing so.
I am using Ubuntu 15.04

So  I went to this page http://www.rubydoc.info/gems/rb-grib/0.2.2
I tried to install requirements for this gem which are 
In order to install grib_api I followed every instructions I can find on web but when it comes to final step in installation (sudo make install) , it gives me an error
"checking for grib_api.h ... no"
"Could not create makefile due to some reason"

I have followed this guide to install grib api Guide
Snapshot of the error I am having in the final command for the api(from the guide link) (make install)
I am really look forward to have some help in installing the rb-grib gem.
Many thanks
Yash


--
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+unsubscribe@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/e4531ddb-373c-4585-b544-74b8b41ba25a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, November 28, 2015

On 28 November 2015 at 19:38, dave <bone_david@mac.com> wrote:
> Hi Group,
> I'm trying to see how Rails at ``startup time'' creates Javascripts within
> the Clientside of the browser.
>
> rails s #starting my program
>
> I've used both Byebug within Ruby code and Firefoxe's debugger within the
> browser.
> ==> Firefox's debug shows me the generated scripts like jquery etc but this
> is after the fact: the code producing the scripts has already executed.
> I want to observe how/when it generates the script and how various
> callbacks are registered particularly in jquery. Eg plot function using
> flot.

All rails does is to package up the js from the relevant gems serve it
on to the browser. If you look in the flot gem you will see
effectively the same javascript that you see in the Firefox debugger.

Colin

--
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+unsubscribe@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/CAL%3D0gLu2tbJp75Axb3bYmPysWqbkvr36FAgYsaraCC5oeyH4mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.