Someone once tried to convince me that something like the following is bad
form:
if obj = get_client
..
end
Not sure why it matters that much or if it should always be avoided .. any
thoughts ?
This used to be very typical in C
--
You received this message because you are subscribed
Generally when tests are written, it seems they never cover all possible
cases. When you are writing code, you might sometimes think of a case where
an unlikely type of input might occur so you convert it from one type to
another. Even if your code has just one or two lines that don't get
nditions you are anticipating in a function,
> you should probably unit test all of those error cases to make sure they
> handle the errors well. Otherwise how do you know you are handling them
> appropriately?
>
> On Wed, Jun 22, 2016 at 3:25 PM, Jedrin <jrub...@gmail.com >
>
This is something I realized is that if you try to write more bullet proof
code, it may have alot of extra checks in it. That may make it harder to
test because there are more conditions. In theory your code is trying to
cover cases that may or may not occur but it is trying to be more robust
Does using Angular with rails imply that I have to only send json data to
the client, all my links have to be handled by angular and I would not use
rails partial rendering ?
That is kind of the impression I get.
Currently I have stuff like this which is not really best practices:
The
I have a helper like this:
def table_elements(qualifier, count)
if qualifier
yield
else
return ("" * count).html_safe
end
end
Then if I do this, what I want to happen is if resp is not null then it
yields the block, otherwise it
yields two empty table cells.
Maybe I could do this .. good idea .. I've been doing too much JavaScript
lately
class NullObject
def self.method_missing(sym, *args, )
return nil
end
end
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe
So this works perfectly but I am not sure why and I suspect I would not get
any points for being elegant. If someone can comment on this or provide a
better solution I would appreciate it
def table_elements(qualifier, count)
if qualifier
yield
return ""
else
I have used Ember.JS a good deal over the past year as well as a little
Angular. I found Ember to have some cool concepts and I liked writing
mixins in Ember, but something about Ember seems very complex to me and I
have felt like I wanted something simpler to work with. I have felt that
I am looking for rails app examples or sql database examples that I can
use to play around with. I am interested in increasing my proficiency with
complex SQL joins, subqueries and the like as well as complex queries
through active record join/include .. Any suggested samples, please let me
There is a rails app that servers an ember.js application via rails-ember
and another site that has the data. Once the ember app is running it gets
ember-data from a data server. In a couple of cases it can also do puts to
the data server via ember data model.save() calls ..
The ember app
The syntax of partial here does not make sense to me. If it was :partial then
it's a symbol, but
what is it this way ?
%= render partial: account %
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To unsubscribe from this group and
of parameters to the render method ?!
2014-03-07 14:54 GMT-03:00 Jedrin jrub...@gmail.com javascript::
The syntax of partial here does not make sense to me. If it was :partial
then it's a symbol, but
what is it this way ?
%= render partial: account %
--
You received this message because you
so this is valid syntax then, I never realized that
{mykey: 'xx''}
= {:mykey=xx}
--
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
I have heard alot about Node.js and watched a few tutorials and read some
stuff. I get the impression that in certain situations AJAX calls with
node.js is alot faster than with rails. I also have somewhat of an
impression that with Rails web sockets are complicated to implement but
with
I was asked an interview question on how I would keep an app's gems up to
date. Suppose there was a new gem because of some security issue for
instance ?
Where I worked before, we locked the gems in the gem file with a
particular version with the notation of something like:
gem
I generated a Rails 4 app. I am not sure why I get the following error.
(in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/turbolinks-1.3.1/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line *#6*):
3456789
head
titleHtspot/title
%=
I've used the various amazon cloud stuff a bit but don't totally
understand it ..
I have a test program below that prints out files and directories I have on
the cloud which has worked fine for me.
When I go to the amazon console, I have to log in using an email address,
then it shows me my
In mongoid, a ORM mapped database object is like below. The part type:
String seems to me to not fit into any standard ruby syntax and I was
curious how does mongoid implement that ?
class Step
include Mongoid::Document
field :Label, type: String
field :Descript, type: String
field
I was told that we can't use mongrel with JRuby because mongrel is GPL and
based on lawyer language if we include mongrel then our code violates some
situation where someone could claim our code should become free. I always
thought this would only apply if we modified the mongrel code base in
On Friday, October 11, 2013 12:13:44 PM UTC-4, Jordon Bedwell wrote:
On Fri, Oct 11, 2013 at 10:55 AM, Jedrin jrub...@gmail.com javascript:
wrote:
I was told that we can't use mongrel with JRuby because mongrel is GPL
and
based on lawyer language if we include mongrel then our
We use twitter bootstrap as it was recommended by a developer here last
year. Everything done in bootstrap kind of has a similar look to it. I feel
like I am a stronger back end developer. I have alot of basic understanding
of HTML/CSS, but it seems there are specialists in front end
We probably need to have a sinatra web server where different clients
through different sessions each have different databases but with the same
tables.
If I have an active record class such as MyFoo, it would be ideal for it to
be for table foo on either db1, db2, etc. If I have MyFoo1 and
I tried to copy all my gems from one machine to another because the
network was down and thus I could not do 'gem install'.
After copying those, when I try to do jruby -S bundle install it can't
find bundle, though if I copied my gems over, supposedly it's there. How
does jruby know the path
I mentioned to someone that I thought Ruby Drb was very elegant and cool,
but after looking at it, they determined it was based on some kind of old
technology was their response, especially since REST is the way to go.
I see why REST has value, but that is the impression all the preaching
We have a sql server database which can have something like 50 meg of
records of any one type. The way that the database was originally designed
with activerecord/sql is that every time you get a couple of million
records or so, it creates a new shard or a new table.
In effect for one record
I am using this jquery file upload plugin. In firefox it has progress
bars, but these don't work in IE.
We are using Sinatra/JRuby/tomcat
This is the plugin:
https://github.com/blueimp/jQuery-File-Upload
I believe the progress bars don't work in IE, because IE doesn't support
that in
I'm obviously implying that the server side progress would involve a
constant ajax polling action to see the progress, but the server would need
to tell me what the progress is
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To
I am using active record find_in_batches() on jruby 1.6.8 (which is ruby
1.8.6 I believe). I just do this:
self.find_in_batches(attr) {|recs|
recs.each { |rec| rec.destroy }}
This leaks memory, however some memory looks like it is freed up each time
but the memory usage
the way the economy is these days and the fact that it was not easy
for me to find my current job, I was wondering if people think it is
acceptable to list my current company as undisclosed corporation or
something like that on my resume. I am not sure exactly why I feel
like doing that, but it
I have this piece of code below. It used to work fine, I was using
active record 2.3.8. I upgraded to
active record 3.2.1 and moved some gems into a gemfile. Now what
happens is rec below is an active record instance, when I enter the
thread it appears to become nil. The method repopulate() is
Ok, I guess that's what it is, I know I have seen something like
that, it's the code blocks that behave differently.
It's sort of interesting that where branching is concerned it works
as bellow where local vars assignments that never get executed get set
to nil as in the value of k
def
I would be curious if someone could explain to me the philosophy of
why k works in my last example the way it does.
As far as the code blocks, I guess they can be standalone, closures,
what not. I'm a bit rusty on what you can do with that sort of thing,
though I have touched on it a bit ..
I guess it kind of makes sense anyway. I feel I can write code better
since now I understand the distinction with the code blocks as opposed
to the branching ..
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To post to this group, send
For some reason I feel a need to initialize variables in some cases as
the way rec is done in
the code below where I do rec = nil. I know ruby would initialize it
by default, but there are some scenarios where I am not sure that is
always the case, but I forget exactly except that it seems like it
As I mentioned in my previous reply and similar to the problem you had when
creating the file: you're trying to load the whole thing.
There are two options for this:
A) You stream the contents of your CSV file, reading by chunks into a
ZipStream
That's exactly what I would like to do, I
I changed the putc about to a write in the above post, followed by
zos.print at the very end. print() adds $\ to the file it appears.
My byte size of the zip file inside the zip was short by two bytes and
I still get corrupted zip file errors on that.
--
You received this message because you
It's late Friday and I am done for the day, but I just tried something
else. It may be that I need to open the file in binary mode and I
didn't. Initial tests seem to indicate that may be the case. Thanks
for everyone's help.
--
You received this message because you are subscribed to the Google
I am using rubyzip and am trying to put a huge csv file with 1.4
million rows into the zip file.
Using jruby I get a out of heap error.
I believe the error happens in the block below:
Zip::ZipOutputStream.open(zip_path) do |zos|
zos.put_next_entry(File.basename(csv_path))
The error happens on the line:
zos.print IO.read(csv_path)
I see that
p zos.class
shows:
Zip::ZipOutputStream
and that the print method is inherited from:
http://rubyzip.sourceforge.net/classes/IOExtras/AbstractOutputStream.html
where print is shown to be this according to doc:
# File
On May 9, 2:42 pm, Greg Akins angryg...@gmail.com wrote:
The default heapsize for the jvm is pretty small. I believe you can pass
args to jvm when you start jruby
if you do something like -xmx1024m (Not sure that syntax is exactly
correct, but it's close) you might get enough. Of course
Greg gave you the answer. A default JVM instance heap space is limited
to 64 Megabytes. If the file you're loading, plus the memory consumed by
your application, goes over that memory limit the JVM will report out
of memory and begin exhibiting unpredictable behavior.
It make no difference
The heap contains all the objects created for the application.. In this
case, it looks like your file is still too big
Error occurred during initialization of VM
Could not reserve enough space for object heap
JVM creation failed
This means that you tried to allocate more than is
Thanks, I have tried the find_each and find_in_batches. I seem to get
a local jump error, yield out of block. Why would that be ?
The approach here is to open the csv for appending after the first
batch, but it doesn't work thus far due to the error.
def self.export_to_csv(attr)
apparently I did not want the each():
self.find_in_batches(attr).each do |recs|
but rather
self.find_in_batches(attr) do |recs|
--
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
I have this sinatra app test where I downloaded a file by hand from
the app and stored it in the test area. I then have my test program
download the same file, save it and compare the two.
The test seems to fail because the one downloaded by hand has
newlines of the form
\r\n whereas the one
I am trying to work with generating really large CSV files from
active record. (This is actually an end case test however) I am trying
this with
a set of active records that is 70 records which is just a test
case that I have, though it is very large. The type of find() below is
supposed to
I get a stack dump in jruby,
it will say: org.jruby.exceptions.RaiseException: (NoMethodError)
undefined method `log' for nil:NilClass
and then print out a lengthy stack dump. None of the source code lines
given however come from any of my code so I am not sure how to figure
out what is causing
Here is a typical stack dump I get. It's looking for a log method on a
nil class. none of it is in my code.
This is a sinatra app. Sinatra seems to not do a good job of tracing
compared to rails is my experience thus far
Application Error
org.jruby.exceptions.RaiseException: (NoMethodError)
I am also using sinatra with this thing called trinidad which is some
kind of web server. When I use web brick I seem to not have soany
problems in this regard. I am not sure why they wanted me to use
trinidad
--
You received this message because you are subscribed to the Google Groups Ruby
We want to use SQL/active record for logging but limit the table size
so that older messages disappear off of the table Some process has to
run periodically to do that.
Suppose I want to keep my table size to not much bigger than
50,000,000 rows or so. What is the easiest, most efficient way to
I sort of knew count() is what I might use even though I said
find(:all), I haven't used count() in a long time and I forget the
syntax and all or how to set it up (it used to have some special set
up in the old rails), but it's still sort of the same problem.
The round robin sounds good, but
Here is another one I don't quite understand. It seems like
RequestLog is used for logging http requests,
but I am not sure how it is getting set up. The second part
where :logger is seen doesn't quite make sense either.
Is the ruby use statement similar to the Perl use statement ? I saw
some
RequestLog is apparently from here:
http://rubydoc.info/gems/request_log/0.1.2/frames
It's starting to make a little more sense, as RequestLog::Middleware
is a class I just realized, but I am not used
to this type of approach ..
module RequestLog
class Middleware
def initialize(app,
We use Sinatra and a Rack middleware called RequestLog
which from my research can be seen here:
http://rubydoc.info/gems/request_log/0.1.2/frames
RequestLog is used for logging and it logs the HTTP requests to
mongodb.
I am supposed to investigate changing the logging of the HTTP
requests to
I do sometimes wonder about one thing, which is that Rails keep
changing and does not have backward compatability in many cases. When
you google for something to try to figure out how to do it in Rails,
you may get some hits from how you might have done it the old way
which has now changed. I am
I don't believe there is any perfect language, thus any language will
have some weakness. Ruby is still my favorite language however.
I do sometimes feel in some ways Java may have some strengths where
Ruby lacks, but I like writing code in Ruby quite a bit.
--
You received this message
Somewhere in all of the ruby code that gets included into this app I
am working on, there is something that defined String so that the
following is a valid statement
puts contact us at + i...@abc.com[] + and say hello
The app that runs, is able to include that stuff and Ruby doesn't
I have been having this problem on windows 7 where I have installed
JRuby, sometimes when I try to install a regular Ruby gem instead of
something for JRuby I get an error message that seems to indicate it
thinks it's for JRuby ..
Below is an example. If I was going to install the gem to JRuby I
I got it to work using the pic gem, I was trying to install watir on
my regular ruby and not jruby. Even though the error said jruby, I did
not invoke jruby gem.
On Apr 13, 3:48 pm, Luis Lavena luislav...@gmail.com wrote:
On Friday, April 13, 2012 10:31:18 AM UTC-3, Jedrin wrote:
I have been
We are using Ruby Sinatra running on JRuby with tomcat as a server.
I saw where it was claimed you could get a console in Sinatra by doing
something like this:
irb -r my_sinatra_app.rb
for me that would be
jruby -S rb my_sinatra_app.rb
but I get this error when I do that as obviously tomcat
I have left my ruby books at home. I am looking at some code that has
stuff like
use Rack::Flash
and some other more complex statements similar to that. I am not sure
what use does and it is too common a word to google. Any links or
explanations would be appreciated ..
Thanks
--
You
I am trying to build a rails app I wrote in JRuby.
When I run bundle install it errors out on
yajl-ruby trying to build it as a native extension. I think it must
have some dependency
with a different gem. How can I figure out what is causing it to want
to use that gem or how to
work around it
Assuming you're using rvm, create a separate gemset and do your
`bundle install` with MRI and then examine the Gemfile.lock that's
been built.
Thanks, but I am on windows. I found a FAQ that says RVM doesn't run
on windows.
--
You received this message because you are subscribed to the
I have a rake file below that forks some processes, but it seems like
it has more processes than I'd expect, yet it only starts one rails
server. I guess I may try to move the fork() calls into a seperate
module
#
def Kernel.is_windows?
processor, platform, *rest = RUBY_PLATFORM.split(-)
I have a process that waits for json messages on a port using event
machine and then publishes them to
faye so that javascript faye clients can subscribe and get updates.
A driver engine runs on the server and creates the json which it
writes to the port and then this process
reads it and
I am working on a website that has a map interface with Openlayers. I
would like to have functionality where I have several points on a map.
If I draw a polygon that encloses some of those points, I would like
to be able to tell which points are within the polygon. That seems
like my main
I have worked at a couple of places where I had a job system
connected to a web portal. The job system used a couple of daemons
that I wrote that connected to the database with active record and ran
various commands in parallel. I had a few Thread.new calls an so on.
At one time I had used
where I said
If I look in the older Rails 3 book that covers
Rails 2.0, it mentions DRb as a viable background task solution.
I meant to say:
If I look in the older Rails Way book that covers
Rails 2.0, it mentions DRb as a viable background task solution.
--
You received this message
I have written some Javascript in some of the Rails sites I've worked
on, but I've tried to avoid it in many or most cases. I have a JQuery
book, but have only really touched on it a little. I did do a bunch of
Javascript on a project several years ago.
When I started using Rails 3, I noticed
I am interested in finding some projects to work on a few hours here
and there to keep up my skills and perhaps add to my resume. I do alot
of backend work and I do not have as big of a visible online portfolio
as some people because I have done alot of things involving internal
web portals for
I wrote a plugin for dealing with logins a few years ago at a company
I worked for. One thing I had was the ability of an admin account to
login as another user so you could see that users views and manage
their accounts. Perhaps I should have used a standard rails plugin,
but I wasn't sure how
You could use pushing from the server instead of
polling.http://railscasts.com/episodes/260-messaging-with-faye
I'll add another railscast that appeared a few weeks later that might
make implementing a push server even
easier:http://railscasts.com/episodes/316-private-pub
Best
Say you have a web page that is supposed to continuously update the
positions of ships in the ocean or something similar. I am wondering
what is a good approach for this ? The page updates automatically
without the user hitting any buttons or clicking on anything.
What occurs to me is a timer
I have a page that has a very large form. That combined with the
database is optimized for flexibility rather than speed with many
joins and the server is not much of a machine and can be very slow
means I would like to consider if I can load the form in pieces via
AJAX. My question is does that
I have been asked a couple of times at job interviews if I am
familiar with HAML or Liquid so I was wondering if maybe I should
start using them and perhaps it would make the views easier to work
with.
If I install HAML on a machine where my app is that has alot of
regular HTML in the .erb
Suppose I have the join as below. Is there a way to make it only
destroy the field_map only when there is no longer a reference to
it ?
has_many :field_map_joins, :dependent = :destroy
has_many :field_maps, :through = :field_map_joins,
:dependent = :destroy
--
You received this
I sometimes get this message on a dev box I log into remotely:
Ruby Interpreter (CUI) 1.9.2p180 [i386-mingw32] has stopped working
A problem caused the program to stop working correctly. Windows will
close the program and notify you if a solution is available.
A note on my latest test with this problem is that if I run the
upload script that uploads pdf files to the rails server and try to
access a web page from a browser on the server while that script is
running, it seems to cause the problem. If I just run the script
without accessing the web page,
This whole system is eventually going to linux at some point, so
hopefully if that happens the diagnostics will be better then ..
--
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
I have this inside of a template where I have a remote form with the
form fields inside of a table:
div id='ingredients_div'
%= render :partial = 'ingredients',
:locals = {:attr = attr} %
/div
my _ingredients.html.erb template is like so:
-
suppose I have a text file and I am looking for a pattern in that file
of the regex form: /^\s*#{label}\s*:?\s*(.*)/i
Where 'label' is a variable, but I want to do something like this:
labels.each do |lab|
if line =~ /^\s*#{lab}\s*:?\s*(.*)/i
matched = lab
end
end
If labels are stored in
If rec is an active record object and you call rec.attribute_names, it
gives you the field names in alphabetical order.
If there is a way to get the order that the fields where created into
the dabatase on the create_table sql call, I would find that very
useful. It seems like there is supposed
.each_with_index do |el,idx|
if !self.attribute_names.include?(el)
del_idxs idx
end
end
puts 'del idx'
puts \n\n\n
del_idxs.each{|i| ar2.delete_at(i)}
ar2
end
On Aug 15, 5:46 pm, Jedrin jrubia...@gmail.com wrote:
If rec is an active record object and you call
I have been having a strange problem with including active record
outside of rails when it works ok in rails 3.0.3.
When I do 'gem list', I get this:
actionmailer (3.0.9, 3.0.3)
actionpack (3.0.9, 3.0.3)
activemodel (3.0.9, 3.0.3)
activerecord (3.0.9, 3.0.3)
activeresource (3.0.9, 3.0.3)
When I run a command program (rails 3/ruby 1.9.2) as this:
class MsdsAttr ActiveRecord::Base
include MsdsAttrModule
belongs_to :attribute_record, :polymorphic = true
has_many :attribute_values, :foreign_key = 'attribute_id'
has_many :alt_values, :as = :alternative
has_many
I haven't done any DRb stuff in awhile, but I used to connect to a DRb
server from
a rails controller. I've never tried it in rails 3 and am wondering if
Rails 3 is stricter about something like this or why it hasn't worked
thus far.
My server/client code and error are shown below:
SERVER:
I am having a problem using the test database in Rails 3. It
apparently has kept track of aspects of the database that I deleted
completely from my migrations at some point. I don't always use the
'down' part of a migration and sometimes just recreate the whole
database. I did rake
No, I hadn't tried that, but I just did the following below along
with that and it is trying to access a table that maybe I had at one
time 'ingredients', but no longer have in my schema or migrations. I
guess I might like to completely destroy my databases and start over.
Not sure the easiest
I have done a little polymorphic associations stuff and have
refreshed my memory on it again.
What it seems like is that if I have a particular record and I want to
make it easy for many different parent records to associate with it
using has_one or has_many, that is fine.
If I want a parent
Say you have a page that you dynamically created with ajax calls and
RJS. Can you somehow get a copy of what that final page looks like and
somehow cache it away and later serve it from the cache ?
A problem seems to be that if you navigate away from a dynamic page
and then hit the back
I created an amazon s3 account and I downloaded s3 browser for
windows here:
http://s3browser.com/
I put my keys in and tried to create a bucket, but it said my s3
account is not valid .. Is it possible it is too new ?
Is there a better free browser ?
Thanks
--
You received this message
I did the following which seems to fix the problem, note the last two
set_style calls take a string rather than a hash:
page[k].set_style({:'font-size' = font_sz, :color = col,
:position = 'absolute', :left = (40
+ (horz)), :top = ((tidx * 100) + 70)
I am trying to get an old web site working. It used
acts_as_attachment for file uploads. Alot of my google searches seem
to show that there are not any recent informational posts on it and
particularly not for Rails 3.
Do I need to use something else ?
What should I try ?
--
You received
I am trying to put my app on heroku, following the instructions, when
I get here I get this error:
$ git push heroku master
Enter passphrase for key '/c/Users/Laurence/.ssh/id_rsa':
Counting objects: 277, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (246/246), done.
In order to work with Robert Half Associates, they want me to sign
this thing that is about 4 pages and says Hourly Employment
Agreement. The first part says Consultant agrees to provide, on an
as needed basis, such IT services required by Robert Half from time to
time .. work provided
I am in the USA. I tend to target mostly Rails work.
Robert Half had called me and said that they had been getting in
Rails contracts and wanted to talk to me. Often times they do not get
so much rails work. I took it as a possible sign of a pickup in rails.
I went to their office and met
I am looking for a job and had talked to a company. The fellow there
encouraged me to make available some sort of code sample of my work. I
took some functionality out of a website I had worked on a few years
ago and created a rails plugin which is now on github here:
Robert Half does have some IT postings for Ruby or related:
http://www.indeed.com/jobs?q=rubyl=Boston,+MArbc=Robert+Half+Technologyjcid=8295f0911ec08bde
--
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
Jason,
Sorry if this is an off topic post. I don't frequent alot of IT
related groups and feel somewhat comfortable what people from the
Rails group might have to say as I have posted on this group a number
of times etc ..
I am not sure I have time for a job counselor or a lawyer on this.
1 - 100 of 155 matches
Mail list logo