[Rails] Re: why is thread asleep?

2012-10-25 Thread John Merlino
Oh I see, because of the call to Kernel.sleep forces the thread in a
sleeping state.

On Oct 25, 9:55 pm, John Merlino  wrote:
> In this example:
>
> 1.9.3p0 :001 > def threading
> 1.9.3p0 :002?>   i = 0
> 1.9.3p0 :003?>   while i <= 50
> 1.9.3p0 :004?>     sleep(2)
> 1.9.3p0 :005?>     i += 1
> 1.9.3p0 :006?>     if i == 50
> 1.9.3p0 :007?>       puts "the thread is finished at #{Time.now}"
> 1.9.3p0 :008?>       end
> 1.9.3p0 :009?>     end
> 1.9.3p0 :010?>   end
>  => nil
> 1.9.3p0 :011 > t = Thread.new { threading }
>  => #
> 1.9.3p0 :012 > t.status
>  => "sleep"
> 1.9.3p0 :013 > t.stop?
>  => true
> 1.9.3p0 :014 > t.alive?
>  => true
> #few minutes later:
> 1.9.3p0 :015 > the thread is finished at 2012-10-25 21:52:43 -0400
>
> As soon as threading is invoked in the new thread, I check its status.
> And the status is "sleep". Why is it "sleep" and not "runnable"?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] why is thread asleep?

2012-10-25 Thread John Merlino
In this example:

1.9.3p0 :001 > def threading
1.9.3p0 :002?>   i = 0
1.9.3p0 :003?>   while i <= 50
1.9.3p0 :004?> sleep(2)
1.9.3p0 :005?> i += 1
1.9.3p0 :006?> if i == 50
1.9.3p0 :007?>   puts "the thread is finished at #{Time.now}"
1.9.3p0 :008?>   end
1.9.3p0 :009?> end
1.9.3p0 :010?>   end
 => nil
1.9.3p0 :011 > t = Thread.new { threading }
 => #
1.9.3p0 :012 > t.status
 => "sleep"
1.9.3p0 :013 > t.stop?
 => true
1.9.3p0 :014 > t.alive?
 => true
#few minutes later:
1.9.3p0 :015 > the thread is finished at 2012-10-25 21:52:43 -0400

As soon as threading is invoked in the new thread, I check its status.
And the status is "sleep". Why is it "sleep" and not "runnable"?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] XML Builder

2012-10-25 Thread Dave Aronson
On Thu, Oct 25, 2012 at 10:26 PM, bwb  wrote:

> Using XML Builder, or some other facility, how does one emit an
> element instance that has both attributes and non-empty content?

Long story short: pass it the content, and then the attributes.  (Or
the other way around, but then I think you'd have to put the
attributes in braces (since it's a hash and you'll have stuff after
it), and put parens on the call (so Ruby doesn't think the hash is a
block).)

In your case, if I correctly spotted the difference between the
current and desired outputs, what I think you want would be:

xml.eotype EoType.find(official.eotypeID).name,
   eotypeID: official.eotypeID
xml.source SourceType.find(official.sourceID).name,
   sourceID: official.sourceID

Or, to reduce unclear redundancy:

eo_id = official.eotypeID
xml.eotype EoType.find(eo_id).name, eotypeID: eo_id
src_id = official.sourceID
xml.source SourceType.find(src_id).name, sourceID: src_id

Or, with the attributes hash first:

eo_id = official.eotypeID
xml.eotype({ eotypeID: eo_id }, EoType.find(eo_id).name)
src_id = official.sourceID
xml.source({ sourceID: src_id }, SourceType.find(src_id).name)

Try any of these (I'd favor #2) and let me know if it gets you what you want.

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking contracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails Services Module

2012-10-25 Thread Matthias Frick
hmm, i understand your opinion, but nowadays it would be very convenient to 
have so a docking station layer.. nearly every rails app interacts with 
external services, so I think it would be a great idea.. more other 
opinions? :)

Am Donnerstag, 25. Oktober 2012 02:27:15 UTC+2 schrieb Fabian Becker:
>
> Matthias, the point is, that not everything has to come with Rails. Lets 
> keep things modular and cleanly separated. Don't try to integrate 
> everything into the Rails core when it can just as well be done withing a 
> Gem.
>
> On Thu, Oct 25, 2012 at 1:36 AM, Matthias Frick 
> 
> > wrote:
>
>> yes i know these gems. but offers rails itself a layer to hook in such 
>> external APIs?
>> like a docking station, where you can register external services and so 
>> on..
>>
>> matthias
>>
>> Am Mittwoch, 24. Oktober 2012 16:05:56 UTC+2 schrieb Matt Jones:
>>>
>>>
>>>
>>> On Tuesday, 23 October 2012 11:23:06 UTC-4, Matthias Frick wrote:

 Rails does not support an interface for external APIs? Or does it 
 offers one?
 For example you have to interact with the facebook graph api, twitter 
 api, and others, is there a main basic end-to-end point for such api's?


>>> Not sure what you mean - the interaction with external services is 
>>> typically done with gems. Some examples:
>>>
>>> Twitter - 
>>> https://github.com/sferik/**twitter
>>> Facebook - 
>>> https://github.com/nsanta/**fbgraph
>>> Git repos - 
>>> https://github.com/mojombo/**grit
>>>
>>> There's also a wide variety of gems that handle the lower-level details 
>>> to make interacting with APIs easier, from HTTParty to RestClient to 
>>> Faraday.
>>>
>>> --Matt Jones
>>>
>>  -- 
>> 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 
>> rubyonra...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> rubyonrails-ta...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/rubyonrails-talk/-/t0KHFPfNtYAJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/4whkHs6z6FYJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: extracting a portion of a model to a separate file

2012-10-25 Thread Frank Mattia
Matt Jones wrote in post #1080951:
> On Friday, 25 June 2010 01:12:47 UTC-4, frankj...@gmail.com wrote:
>> I have a ton of models that each have fairly complex state machines.
>>
>> My state_machine blocks however are very large and clutter up my
>> model.rb files...
>>
>> What I want to do is extract out all of the state machine code to
>> another file that I can then "include" in my model. I know include is
>> the wrong terminology in ruby.. maybe I want to modularize them?
>>
>
>  One mechanism that can be helpful that hasn't been mentioned -
> ActiveSupport::Concern. See here for more detail:
>

Funny, as soon as I came back to check the update I said to myself 
"knowing what I know now, I would have probably used a concern". I 
second your suggestion.

> 
http://www.fakingfantastic.com/2010/09/20/concerning-yourself-with-active-support-concern/
>
> --Matt Jones

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: XML Builder

2012-10-25 Thread bwb
My previous post on this question had an error in the resired target 
description.  Here is it aagain; apologies for any confusion:

my code looks like this:
xml.instruct!
xml.county(name: @jurisdiction.name, id: @jurisdiction.jurisdictionID) do
  xml.officials do
@officials.each do |official|
  xml.official do
xml.firstname official.firstname
xml.lastname official.lastname
xml.eotypeID eotypeID: official.eotypeID
xml.eotype EoType.find(official.eotypeID).name
xml.sourceID sourceID: official.sourceID
xml.source SourceType.find(official.sourceID).name
  end
end
  end
end

which produces this:


  

  Hector
  Someone
  
  Primary
  
  State Web Site


  Lucy
  Someone-Else
  
  Registration
  
  History

  


I would like to change it to produce this:


  

  Hector
  Someone
  Primary
  Web Site


  Lucy
  Someone-Else
  Registration
  History

  


I cannot find any documentation or examples on the point. Can someone offer 
a helpful hint or point to some useful documentation that covers the 
subject, where the primary point is this:  Using XML Builder, or some other 
facility, how does one emit an element instance that has both attributes 
and non-empty content?  There are losts of ways to do it with brute force; 
just trying to find an "elegant" solution.

Thanks for any suggestions

On Thursday, October 25, 2012 6:26:46 PM UTC-4, bwb wrote:
>
> my code looks like this:
> xml.instruct!
> xml.county(name: @jurisdiction.name, id: @jurisdiction.jurisdictionID) do
>   xml.officials do
> @officials.each do |official|
>   xml.official do
> xml.firstname official.firstname
> xml.lastname official.lastname
> xml.eotypeID eotypeID: official.eotypeID
> xml.eotype EoType.find(official.eotypeID).name
> xml.sourceID sourceID: official.sourceID
> xml.source SourceType.find(official.sourceID).name
>   end
> end
>   end
> end
>
> which produces this:
>
> 
>   
> 
>   Hector
>   Someone
>   
>   Primary
>   
>   State Web Site
> 
> 
>   Lucy
>   Someone-Else
>   
>   Registration
>   
>   History
> 
>   
> 
>
> I would like to change it to produce this:
>
> 
>   
> 
>   Hector
>   Someone
>   
>   Primary
>   
>   Web Site
> 
> 
>   Lucy
>   Someone-Else
>   Registration
>   History
> 
>   
> 
>
> I cannot find any documentation or examples on the point. Can someone 
> offer a helpful hint or point to some useful documentation that covers the 
> subject, where the primary point is this:  Using XML Builder, or some other 
> facility, how does one emit an element instance that has both attributes 
> and non-empty content?  There are losts of ways to do it with brute force; 
> just trying to find an "elegant" solution.
>
> Thanks for any suggestions
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/hUmakDHUs20J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] XML Builder

2012-10-25 Thread bwb
my code looks like this:
xml.instruct!
xml.county(name: @jurisdiction.name, id: @jurisdiction.jurisdictionID) do
  xml.officials do
@officials.each do |official|
  xml.official do
xml.firstname official.firstname
xml.lastname official.lastname
xml.eotypeID eotypeID: official.eotypeID
xml.eotype EoType.find(official.eotypeID).name
xml.sourceID sourceID: official.sourceID
xml.source SourceType.find(official.sourceID).name
  end
end
  end
end

which produces this:


  

  Hector
  Someone
  
  Primary
  
  State Web Site


  Lucy
  Someone-Else
  
  Registration
  
  History

  


I would like to change it to produce this:


  

  Hector
  Someone
  
  Primary
  
  Web Site


  Lucy
  Someone-Else
  Registration
  History

  


I cannot find any documentation or examples on the point. Can someone offer 
a helpful hint or point to some useful documentation that covers the 
subject, where the primary point is this:  Using XML Builder, or some other 
facility, how does one emit an element instance that has both attributes 
and non-empty content?  There are losts of ways to do it with brute force; 
just trying to find an "elegant" solution.

Thanks for any suggestions

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/nV3s1ulAMxUJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread Jason Walsh
webber han wrote in post #1081214:
> Jason Walsh wrote in post #1080993:
>> Am having real probs trying to use Ajax with my Rails app. I have set up
>> a test as
>>
>> follows:
>>
>> in javascript file:
>>
>> window.onload = function() {
>> $('#test').bind('ajax:success', function() {
>> alert("success");
>> };
>> }
>> in view:
>>
>> <%= link_to "test", { :action => :getDiagram }, :remote => true, :id =>
>> "test" %>
>> in controller:
>>
>> def getDiagram
>>
>> end
>>
>> Now I know this looks odd with the empty controller action, but I would
>> expect this code to just show a popup window with 'success' and leave
>> the current page loaded when the link is clicked? Instead i get the
>> missing template message like its trying to load a page synchronously
>> rather than using ajax?
>>
>> Can anyone get my test to work? Do I need to upgrade or add a gem file?
>>
>> Thanks in advance
>>
>> Jason
>
> What I have noticed is that
> 1. The javascript syntax is not correct
> 2. You didn't specify a controller from the link
> 3. It is probably make more sense to test with Json response using
> respond_to :json
> respond_with { :status => 'okay' }

Thanks Webber

1. Noticed the missing bracket and fixed.
2. Have set a route as follows:
match '/getdiagram', :to => 'prosesses#getDiagram'
It seems to be executing the right controller/action from the error 
message i get
3. Tried that but get:
c:/Users/Jason/rails_projects/procstor/app/controllers/prosesses_controller.rb:123:
 
syntax error, unexpected tASSOC, expecting '}'
respond_with { :status => 'okay' }
 ^

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread Jason Walsh
Frederick Cheung wrote in post #1081170:
> On Wednesday, October 24, 2012 7:40:24 PM UTC+1, Ruby-Forum.com User
> wrote:
>> alert("success");
>> };
>> }
>>
>
> This javascript is syntactically incorrect - you're not closing the
> parens
> you open just after "bind"
> Also if you want to render nothing you do need to explicitly say that
> (eg
> render :nothing => true) or rails will complain that there is no
> template
>
> Fred

Thanks Fred

I spotted that using Firebug, but still makes no difference.  When 
setting render :nothing => true it just renders a blank template which 
is not what i want.  The ajax:success event is not firing either

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread Jason Walsh
AndreM wrote in post #1081168:
> Maybe try in controller:
>
> def getDiagram
>
> respond_to do |format|
>   format.js
> end
>
> end

Hi Andre

Tried that - dont get error but renders a blank template.  My main 
concern is why the event isnt firing and showing the alert.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread webber han
Jason Walsh wrote in post #1080993:
> Am having real probs trying to use Ajax with my Rails app. I have set up
> a test as
>
> follows:
>
> in javascript file:
>
> window.onload = function() {
> $('#test').bind('ajax:success', function() {
> alert("success");
> };
> }
> in view:
>
> <%= link_to "test", { :action => :getDiagram }, :remote => true, :id =>
> "test" %>
> in controller:
>
> def getDiagram
>
> end
>
> Now I know this looks odd with the empty controller action, but I would
> expect this code to just show a popup window with 'success' and leave
> the current page loaded when the link is clicked? Instead i get the
> missing template message like its trying to load a page synchronously
> rather than using ajax?
>
> Can anyone get my test to work? Do I need to upgrade or add a gem file?
>
> Thanks in advance
>
> Jason

What I have noticed is that
1. The javascript syntax is not correct
2. You didn't specify a controller from the link
3. It is probably make more sense to test with Json response using
respond_to :json
respond_with { :status => 'okay' }

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Not updating the updated_at field

2012-10-25 Thread Matt Jones


On Tuesday, 23 October 2012 05:09:50 UTC-4, Peter Hickman wrote:
>
> This is for Rails 3.1.1 
>
> I have a field called last_seen in a model. This field will be updated 
> when the something about the record is seen in the real world (don't 
> worry about this part) 
>
> So I go x.update_attribute(:last_seen, Time.now) and the following happens 
> is 
>
> UPDATE "blah" SET "last_seen" = '2012-10-23 08:57:46.179288', 
> "updated_at" = '2012-10-23 08:57:54.872808' WHERE "blah"."id" = 2673 
>
> Now, just for this one attribute, I would like the updated_at field to 
> be unmolested. Is there some way of updating the last_seen field 
> without ActiveRecord updating the updated_at field? 
>

update_column will do exactly what you're looking for, and has the 
advantage of not being on the short list to go away in Rails 4.1 like 
update_attribute. :)

--Matt Jones 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/iv8sH65CLXwJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Run rails application without installing rails

2012-10-25 Thread Walter Lee Davis

On Oct 25, 2012, at 1:34 AM, ruby rails wrote:

> Is it possible to run a rails application without installing rails gem
> in ubuntu system.?? If yes, please provide me some reference for it.
> 

I suppose you could "vendor" the entire application, which would remove the 
need to install the entire stack on the server directly. I mean, it would still 
be installed, it just wouldn't be in the /usr/local/lib tree. Is that what you 
mean? There's also jRuby, where you pack the entire app into a WAR file or 
something like that -- nothing I've ever tried myself.

Walter

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread Frederick Cheung


On Wednesday, October 24, 2012 7:40:24 PM UTC+1, Ruby-Forum.com User wrote:
>
> Am having real probs trying to use Ajax with my Rails app. I have set up 
> a test as 
>
> follows: 
>
> in javascript file: 
>
> window.onload = function() { 
> $('#test').bind('ajax:success', function() { 
> alert("success"); 
> }; 
> } 
>

This javascript is syntactically incorrect - you're not closing the parens 
you open just after "bind"
Also if you want to render nothing you do need to explicitly say that (eg 
render :nothing => true) or rails will complain that there is no template

Fred

>
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/c5f5jNuM62EJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ajax test not working

2012-10-25 Thread AndreM
Maybe try in controller:

def getDiagram

respond_to do |format|
  format.js
end 

end 


On Wednesday, October 24, 2012 8:40:24 PM UTC+2, Ruby-Forum.com User wrote:
>
> Am having real probs trying to use Ajax with my Rails app. I have set up 
> a test as 
>
> follows: 
>
> in javascript file: 
>
> window.onload = function() { 
> $('#test').bind('ajax:success', function() { 
> alert("success"); 
> }; 
> } 
> in view: 
>
> <%= link_to "test", { :action => :getDiagram }, :remote => true, :id => 
> "test" %> 
> in controller: 
>
> def getDiagram 
>
> end 
>
> Now I know this looks odd with the empty controller action, but I would 
> expect this code to just show a popup window with 'success' and leave 
> the current page loaded when the link is clicked? Instead i get the 
> missing template message like its trying to load a page synchronously 
> rather than using ajax? 
>
> Can anyone get my test to work? Do I need to upgrade or add a gem file? 
>
> Thanks in advance 
>
> Jason 
>
> -- 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/Rbq35V6EY2cJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: calling java application (BIRT) from rails application

2012-10-25 Thread Rahul Kumar
Kad Kerforn wrote in post #1081147:
> I guess BIRT java app already has a javascript API  you can call from
> your
> Rails-Ruby app
> someone already worked it :
> see :  https://github.com/casp/Birt-library-for-Ruby
> this guy may help you
>
>
> Le jeudi 25 octobre 2012 09:34:17 UTC+2, Ruby-Forum.com User a crit :


But how to run birt viewer so that we can have many options to download 
the report, like in pdf,excel,csv etc.. so how do you collaborate birt 
viewer into rails.
Thanks in advance.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: calling java application (BIRT) from rails application

2012-10-25 Thread Erwin
I guess BIRT java app already has a javascript API  you can call from your 
Rails-Ruby app
someone already worked it :
see :  https://github.com/casp/Birt-library-for-Ruby
this guy may help you


Le jeudi 25 octobre 2012 09:34:17 UTC+2, Ruby-Forum.com User a écrit :
>
> How to call java based application (BIRT) from a rails application . 
> pLease help.Do I require RJB or Jruby or is there any other way to get 
> this thing done . please can you explain in detail. please help 
>
> -- 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/ouCOyuVRB-wJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] [Rails 3.2.8] ActiveSupport::BufferedLogger extension, undefined_method

2012-10-25 Thread Erwin
I tried to extend it , with this class , loaded at config time :
  config.autoload_paths += Dir["#{config.root}/lib", 
"#{config.root}/lib/**/", "#{config.root}/app/inputs"]

lib/extension.rb
class ActiveSupport::BufferedLogger
  def detailed_error(e)
error(e.message)
e.backtrace.each{|line| error line }
  end
end

but calling it in my controller 

rescue ActiveRecord::RecordInvalid
   logger.detailed_error($!)

raises an error =>   undefined method `detailed_error' for 
#
what's wrong with my class definition ?

thanks for feedback

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/4gnQaitFTv4J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Uniqueness and sql serialize

2012-10-25 Thread Filipe Giusti
Hi fellow programmers,

I was looking for how to keep integrity in some financial transactions and 
I saw this "This could even happen if you use transactions with the 
‘serializable’ isolation level." in the uniqueness page 
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of.
 
How this is possible with the serializablo isolation level? Aren't the 
select and update done in the same transaction?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/EViXJ9zmSY8J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] How to consume HTTP Streams/Chunk requests in Rails

2012-10-25 Thread Frank
Hi all,

Can't seem to find out how I can process an http chunk request (like the 
twitter fire hose stream) from within a rails app, server side. Can anyone 
point me in the right direction?

Tried to connect using Net:HTTP but never received a response from the end 
point.

Thank,

Frank

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/xug_-5v_BWkJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] JQuery-File-Upload Button dependencies

2012-10-25 Thread akvarel
I am using this application 
exampleand 
try to model it to fit my needs.


I am modelling your index.html.erb to fit my needs.
I want to get rid of "start" button in order to prevent single-file upload 
(I dont want it), but it seems that "start upload"(multiple upload)-button 
is on "start" button dependent and I could not find how to modify the 
script in order to get rid of "start"-buttom but to keep the functionality 
of a "start upload" -button.

Can you give me some hints how to get rid of those dependencies?


Hier is the short code cut-off:
I have marked the lines where "start upload" and "start" buttons are 
situated with !!!.


  Upload file
  <%= form_for Upload.new, :html => { :multipart => true, :id => 
"fileupload" } do |f| %>


  


  
  Add files...
  <%= f.file_field :upload %>


  
 Start upload


  
  Cancel upload


  
  Delete


  
  


  

  







  <% end %>






  {% for (var i=0, file; file=o.files[i]; i++) { %}
  

{%=file.name%}
{%=o.formatFileSize(file.size)%}
{% if (file.error) { %}
{%=locale.fileupload.error%} 
{%=locale.fileupload.errors[file.error] || file.error%}
{% } else if (o.files.valid && !i) { %}

  
!!! {% if (!o.options.autoUpload) { %} {% } %} {% } else { %} {% } %} {% if (!i) { %} {% } %} {% } %} $(function () { // Initialize the jQuery File Upload widget: $('#fileupload').fileupload(); // // Load existing files: $.getJSON($('#fileupload').prop('action'), function (files) { var fu = $('#fileupload').data('fileupload'), template; fu._adjustMaxNumberOfFiles(-files.length); console.log(files); template = fu._renderDownload(files) .appendTo($('#fileupload .files')); // Force reflow: fu._reflow = fu._transition && template.length && template[0].offsetWidth; template.addClass('in'); $('#loading').remove(); }); }); Thank you. Cheers, Katja -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/hQQHHMs_Z0oJ. For more options, visit https://groups.google.com/groups/opt_out.

[Rails] Re: My first database model - would you look at it pls?

2012-10-25 Thread Kevin McCaughey
*Please excuse my bad typing in the previous post - just getting my 
first coffee of the morning before starting learning again and my brain 
is still asleep ;)

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: My first database model - would you look at it pls?

2012-10-25 Thread Kevin McCaughey
Thanks a lot guys! I really appreciate the help. I don't have 1000 users 
yet as I am out of work, but this system is something I was inspired by 
a work problem, and I hoping it gives me enough experience to maybe get 
a junior programming job once I am finished. I was a programmer some 
years ago but recently my career has been elsewhere.

I would love to get back into programming again and, despite some 
frustrations, I am loving Rails and databases :)

Thanks again for your help.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] validation check

2012-10-25 Thread Colin Law
On 24 October 2012 22:01, Werner Laude  wrote:
>
> Am 24.10.2012 um 22:32 schrieb Colin Law :
>
> Hi Colin..

Please don't top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message.  Thanks.

>
> <%= f.collection_select :parent_id, Project.mainprojects.active, :id, 
> :project_name, :include_blank => 'Partproject?', :allow_nil => true%>
>
>  the project_id .. 1, 2 etc. or ""
>
> "parent_id"=>"1"
> "parent_id"=>""

You said in your initial post that you were testing it in the model.
What do you mean by "parent_id" => ""?  In the model it should
probably be an attribute self.parent_id, but in that case I would
expect it to be nil if it is a foreign key.

If you are trying to test it in the controller then it depends what
you are trying to do.  Show us the code you have tried (for the
action, not just one line out of context).

Colin

>
> Werner
>
>
>
>> On 24 October 2012 21:01, Werner  wrote:
>>> Hi..
>>> I have a select which I want to validate if a value is selected, otherwise
>>> not.
>>>
>>> <%= f.collection_select :parent_id, Project.mainprojects.active, :id,
>>> :project_name, :include_blank => 'Partproject?', :allow_nil => true%>
>>>
>>> how is the correct way..?
>>>
>>> tried..in model
>>> if :project_id
>>> if :project_id?
>>> if :project_id.blank?
>>>
>>>
>>> etc . etc.
>>> But nothing works..
>>
>> So what is the value of project_id that you are trying to test for?
>> If you are not sure then have a look at the Rails Guide on debugging
>> which will show you techniques that you can use to debug your code.
>> Then you can find out what is the value of project_id and why your
>> tests are not working.
>>
>> Colin
>>
>> --
>> 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@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> rubyonrails-talk+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> Werner Laude
> webagentur.la...@gmail.com
>
>
>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Error while embedding ruby code in fullcalendar jquery to display events

2012-10-25 Thread ruby rails
I am trying to display events on my fullcalendar. In my controller I am
getting an array of events. But I need to loop it and render it in view
page as events array. When I try to do loop it I am getting some syntax
error on which I have spent around 3-4 hours and couldn't figure it out.
Please help. Please find the code



> $(document).ready(function()
> Blockquote

{ $('#calendar').fullCalendar({
>   editable: true,
>   header: {
>   left: 'prev,next today',
>   center: 'title',
>   right: 'month,agendaWeek,agendaDay'
>   },
>   height: 500,
>   slotMinutes: 15,
>
>   events: [<%@projects.each do
|p|%>{name:<%=p.name%>,start_date:<%=p.start_date%>,end_date:<%=p.end_date%>}<%end%>]
>  });
>   });

In my controller I get the @projects as an array.

But in the console I get the following error as

Timestamp: Thursday 25 October 2012 01:06:22 IST
Error: SyntaxError: missing } after property list
Source File: http://localhost:3000/dashboard?user=9
Line: 44, Column: 33
Source Code:
events: [{name: Online book store,start_date: 2012-01-10}{name: Customer
Service,start_date: 2012-10-18}],

The proper format which I need of this events array is as follows

events: [
{
title: 'All Day Event',
start: 28-10-2012
},
{
title: 'Long Event',
start: 25-10-2012,

},
{

title: 'Repeating Event',
start: 20-10-2012,

}

]

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] calling java application (BIRT) from rails application

2012-10-25 Thread Rahul Kumar
How to call java based application (BIRT) from a rails application .
pLease help.Do I require RJB or Jruby or is there any other way to get
this thing done . please can you explain in detail. please help

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.