hi
I have this code:
Shoes.app do
data = [1,2,3,4] # could be also more
data.each { |i|
edit_line ("foo"){ puts i}
}
end
when the value (foo) change in the edit_line field, I see in the terminal 1,2,3 or 4. But I need the value (.txt) from each edit_line field. How can I reference to it?
The problem is that data is dynam...
Hello!
I need ERB (Ruby's templating system) for templating of non-HTML files.
(Instead, I want to use it for source files such as .java, .cs, ...)
How do I "execute" Ruby templates from command line?
...
I'm sure this is simple but I can't seem to get it:
Works:
@build1 = Booking.build_booking('2009-06-13',3,2,18314)
@build2 = Booking.build_booking('2009-06-13',3,4,18317)
@build = @build1 + @build2
What I want to work...
#for item in @cart.items do
# @build << Booking.build_booking('2009-06-13',3,2,18314)
#end
Doesn't work either...
Hi all,
I've been trying to get RSpec running under Ruby 1.9, and my tests just aren't running. Here's my trace:
matt@matt-desktop:~/Development/my_app$ sudo rake spec --trace
(in /home/matt/Development/my_app)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** I...
I have successful executed following commands:
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local/fcgi
make && make install
tar xzvf ruby-fcgi-0.8.7.tar.gz
cd ruby-fcgi-0.8.7
ruby install.rb config -- --with-fcgi-include=/usr/local/fcgi/include --with-fcgi-lib=/usr/local/fcgi/lib
But I get this error when I r...
When using 'net/https' and ssl, how do I disable verification of the resulting SSL certificate?
...
Hi,
Is there a more 'DRY' way to do the following in ruby?
#!/usr/bin/env ruby
class Volume
attr_accessor :name, :size, :type, :owner, :date_created, :date_modified, :iscsi_target, :iscsi_portal
SYSTEM = 0
DATA = 1
def initialize(args={:type => SYSTEM})
@name = args[:name]
@size = args[:size]
@type ...
I am trying to figure out a 'proper' way of sorting UTF-8 strings in Ruby on Rails.
In my application, I have a select box that is populated with countries. As my application is localized, each existing locale has a countries.yml file that relates a country's id to the localized name for that country. I can't sort the strings manually i...
I'm looping over a series of urls and want to clean them up
I currently have the following code
# Parse url to remove http, path and check format
o_url = URI.parse(node.attributes['href'])
# Remove www
new_url = o_url.host.gsub('www.', '').strip
How can I extend this to remove the subdomains that may exist in some urls?
...
Occasionally when accessing OpenX 2.8.1 via its XMLRPC api (using the ruby 'openx' gem), I will get this error message:
Session ID is invalid
I cannot find anything in OpenX's forums about this, nor via some Google searching.
I am starting to suspect that it is a bug or other issue in the ruby gem itself.
Has anyone else encounte...
I have the following hash:
user = {
'user' => {
'title' => {'weight' => 1, .... }
'body' => {'weight' => 4, ....}
....
....
}
}
Is is possible to get the User sorted by the weight key of its child hashes?
I looked in the Hash.sort, but it looks like it returns array rather than my original hash sorted.
...
I have a mystifying problem. In a very simple Ruby app i have three classes: Drivers, Jobs and Vehicles. All three classes only consist of Id and Name. All three classes have the same #index and #show methods and only render in JSON or XML (this is in fact true for all their CRUD methods, they are identical in everything but name). There...
I'd like to install a plugin but I'm afraid it's going to install a lot of unnecessary stuff. I'd like to look at whatever file rake takes it installation instructions from and remove anything unnecessary.
I believe this is the Rakefile. But I'm not sure what happens when rake looks at the rakefile - does it execute the entire rakefile ...
Hi,
I have a curiosity question. If I have a ruby class and then I dynamically add class methods, class variables, etc. to it during execution is there anyway for me to save the altered class definition so that next time I start my application I can use it again?
...
I just installed a gem but when I type
gem_name --help
It says:
'gem_name' is not recognized as an internal or external command
However, when I type
gem list --local
the gem shows up in the list so I know it's there - I just don't know how to see what it does.
Is there a different instruction to use to find out what commands ...
I need to write a super fast Ruby application to process web requests on Sinatra - and want to run it on the Ebb webserver. But I cannot work out how to do this. Could someone please help me?
...
I'm developing an application, that makes use of some REST web services.
It's technical documentation says that I should pass SHA256 hash of some string in the request.
In an example request (in the documentation) a string:
hn-Rw2ZHYwllUYkklL5Zo_7lWJVkrbShZPb5CD1expires=1893013926label[0]=any/somestatistics=1d,2d,7d,28d,30d,31d,life...
Is there an easy way to obtain the average of an attribute in a collection?
For instance, each user has a score.
Given a collection of user(s) (@users), how can you get the average score for the group?
Is there anything like @users.average(:score)? I think I came across something like this for database fields, but I need it to work f...
I would like to do something like the following:
class String
def fancy_thing appendix
# Just a trivial example to ensure self and params work.
# Pretend this is something complex.
self.reverse + appendix
end
end
# print_method on instance or class should spit out a string
# containing the actual code for that method
ft_c...
Is it possible to redirect using a POST method ?
Or should redirects always be made using GET ?
The use for this is in the final steps of an order process for an e-commerce site, to send the data to the payment processor, without introducing an extra step for the user.
...