I have a User model with a number of very similar properties that I want to list without typing each on in individually.
So, rather than:
"eye color: #{@user.his_eye_color}"
"hair color: #{@user.his_hair_color}"
"height: #{@user.his_height}"
"weight: #{@user.his_weight}"
...
"eye color: #{@user.her_eye_color}"
"hair color: #{@user.her...
I'm working on a Jekyll site and am trying to output three column divs nested in a row div. Liquid makes this pretty easy with their cycle filter:
{% for p in site.categories.post %}
{% cycle 'add rows': '<div class="row">', nil, nil %}
<div class="column">
<a href="{{ p.url }}">{{ p.title }}</a>
</div>
...
Running the command jruby -S spec gives the following error
No such file, directory, or command -- spec
The location of spec is /usr/bin, which is in the path. Rspec is installed. MRI Ruby can find the script. JRuby can find the rspec gem. So what goes wrong?
...
I have found many guides laying out how to do things like adding rake tasks to a continuous build server that utilize metric_fu for a rails project. However, if I have a simple ruby-only project, how can I run metric_fu to show me complexity measures and code smells? It seems like it would involve setting up a rake task or something, b...
Hi,
I've just had a new VPS set up and have installed Passenger with Ruby Enterprise Edition.
However, I can't get rake to work.
/opt/ruby-enterprise-1.8.7-2010.01/bin/gem list
* LOCAL GEMS *
actionmailer (2.3.5, 2.2.3)
actionpack (2.3.5, 2.2.3)
activerecord (2.3.5, 2.2.3)
activeresource (2.3.5, 2.2.3)
activesupport (2.3.5, 2.2.3)
fa...
I'm using a public Windows computer where the command line has been disabled. By using Instant Rails I'm able to create customize and test rails apps to some degree but can't use the Rails commands.
Question:
How do I use these commands with a disabled command line?
I've tried using SciTe, Notepad++ but all these just access the same ...
I have a gem that requires a 'Cms' namespace to be present when running.
However, when running rake tasks, nothing works as this Cms namespace isn't present. How do I get my rake tasks to work?
...
My project doesn't use the plural convention in table's names.
How can I override this convention
without calling set_table_name in all my ActiveRecord class
...
Hi,
Could you tell me plz - how to catch system information like os version, installed apps versions, hardware details using macruby or ruby cocoa?
...
Is the following inefficient? I want to allocate nearly all resources to threads but I'm wondering if in this case this loop will consume a lot of CPU time.
Thanks!
threads = create_threads #method that returns an Array of Threads
loop do
alive = false
threads.each do |thread|
if thread.alive?
alive = true
end
end
...
Hi there,
I've got a sweeper that's supposed to expire a few action caches. Even though the debugger stops immediately before the call to expire_action, it's not actually expiring the action. Any idea what could be going on?
Here are the relevant sweeper and controller.
#company_sweeper.rb (in 'models' directory)
class CompanySweeper ...
I'm trying to learn ruby on rails. I've been going through a tutorial, but I've gotten stuck.
It has me using start_form_tag and end_form_tag around an input form. However, when I access the page, I get undefined method 'start_form_tag' for #<ActionView::Base:0x2556020>
In the tutorial, they explain that these two lines are transla...
As far as I know, JRuby runs only on full JVM. I found this version of JRuby which runs on Java Micro Edition devices, however it's marked as EXPERIMENTAL AND RESEARCH ONLY
Are there any other options for running Ruby application on Windows Mobile devices?
...
I call Ruby functions from my C++ code through the embedding commands (rb_eval and the like). Is there any way to stop the execution of the code partway, save the local variables, and restart it from the same spot later?
...
As much I would like to I still don't know how to implement metaprogramming.
For views rendered from my Admin::Base controller I would like override the Rails compute_public_path located under ActionView::Helpers::AssetTagHelper, so that all my admin's layout files will be under public/admin.
There is probably a better way to this, but...
Hello. I'm trying to extract information from an email address like so in ruby:
Email: Joe Schmo <[email protected]>
to get these three variables:
name = ?
email = ?
domain = ?
I've tried searching everywhere but can't seem to find how to do it correctly. Here's what I have so far:
the_email_line = "Email: Joe Schmo <joeschmo@ab...
I have code that sorts the way I want. By multiple fields. Cool. But now I realized that sometimes the elements could be nil.
Q1: Any idea how to manage to get nil values at the top of the search? And get rid of this error message :in "<=>": undefined method "<=>" for nil:NilClass (NoMethodError)
Q2: in the code below I sort by 3 elem...
Is there a more compact way to write the following code. I would like to get rid of the line that assigns the empty string when flash[:add_run_error] is nil.
unless run.save
run.errors.each do |attr, msg|
flash[:add_run_error] += '<br/>' if flash[:add_run_error]
flash[:add_run_error] = '' unless flash[:add_run_error]
...
I read my csv using the line below
data = FCSV.table("test.csv", {:quote_char => '"', :col_sep =>',', :row_sep =>:auto, :headers => true, :return_headers => false, :header_converters => :downcase, :converters => :all} )
QUESTION
Can I save object data in the same manner (one line, one go + csv options)? see above
I sort the table (s...
Say I have a ruby method:
def blah(foo=17)
...
end
In code I want to invoke blah with a specific argument "blah(a)" or invoke blah using its default argument "blah()" Is there any way to do that without specifying the method name twice? I'm trying to avoid:
if a.nil?
blah()
else
blah(a)
end
Because it makes the code look m...