I am building a sample site to familiarize myself with RoR. I followed the book "Agile Web Development with Rails" up to a point, and now I am experimenting and using it as a reference, however I haven't been able to find the answer to my problem.
I have two models of interest, one is supermarketchain and the other supermarket. Obvious...
I've written a Ruby script that is reading a file (File.read()) that contains unicode characters, and it works fine from the command line.
However, when I try to put it into an Automator Workflow (Mac OS X), I get this error;
2009-12-23 17:55:15 -0500: /Users/jeffreyaylesworth/bin/symbols:19:in `split': invalid byte sequence in US-ASCI...
The Ruby in Tim Bray's Wide Finder benchmark (http://wikis.sun.com/display/WideFinder/The+Benchmark) has this line:
%r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+) }
I've been using regexes for a long time, but I'm not sure what the point of the "." is. It seems to match on anything that's not a space, but [^ ] would do that...
I'd like to write this:
[:p, :h1, :h3].each do |tag|
define_method(tag) { |text| "<#{tag}>#{text}</#{tag}>" }
end
It's just some simple methods to wrap text in HTML tags. I want to be able to use these methods in the rest of the script. Unfortunately the define_method method seems to only work inside of a module. But if I did thi...
I do something like sudo gem install json. Then I do irb. Then I do require 'json'. Then it says no such file to load -- json
...
My application controller looks like this
class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :all # include all helpers, all the time
protect_from_forgery # :secret => 'sup3rs3cr3t'
filter_parameter_logging :password
# Here's the interesting bit
before_filter :login_required, :except => ...
I'm trying to download the last successful build from TeamCity as part of our rake deployment script. The file is a zip file that is 8mb, and I get over http, using a url:
http://buildserver/guestAuth/repository/download/bt12/.lastSuccessful/Build.7z
If I open that url in Firefox, the zip file downloads in about 1-2 seconds. Basically ...
Hi.
I have an object in Ruby called Post.
I would like to convert post into an json but also I want to include the name of the user who posted the post. The thing is user_name is not present in Post object but the user id is.
So what I effectively want is something like this
{name:"My Post", body:"My post data", user_name:"jhonny"}
...
I have tried MongoMapper and it is feature complete (offering almost all AR functionality) but i was not very happy with the performance when using large datasets. Has anyone compared with Mongoid? Any performance gains ?
...
Language: Ruby
I have an array of Products. Each Product has an attribute called product_price_name.
[Product.product_price_name = "All Prices", Product.product_price_name = "$1 to $100" ]
I want to sort this array so the first result is "All Prices" and then the next options will be price ranges such as $1- $100, $100- $200
...
Hello all!
I'm a newbie in rails, and I've been looking all over for an answer for this issue. Here's what I have:
class Item < ActiveRecord::Base
belongs_to :book
class Book < ActiveRecord::Base
has_many :items
Now I want to list all the items with their properties and the book associated with them. They would go under index in ...
I have the following code in an Active Record file.
class Profile < ActiveRecord::Base
attr_accessor :tmp_postal_code
def postal_code=(postal_code)
@temp_postal_code = postal_code[:first] + "-" + postal_code[:second]
end
def postal_code
@temp_postal_code
end
end
I first overwrote postal_code=(postal_code) because p...
I'm currently writing a C extension for ruby as part of a project of mine. The extension is to implement an algorithm I have already working in ruby in C for performance reasons. The question I pose though is whether I should use ruby's own data types in the C code or convert them to C's native types for performance reasons?
Would such...
how can I configure Ruby web client to request web pages using Tor ?
...
I have an edit screen for a model that's nested inside 2 other resources. To make the example easy to understand, it looks sort of like this:
Make -> Model -> Car
I have a Car edit screen that lets you edit the few fields that it contains.
(assume the url is: /makes/124/models/12512/cars/1125/edit)
I want to add a cascading pair of...
Hi,
i'm working with some codes that has a:
begin
require 'digest/hmac'
USE_EMBEDDED_HMAC = false
rescue
puts "HMAC, not found in standard lib." + $!.message
require 'hmac-sha1'
USE_EMBEDDED_HMAC = true
end
As i could see, at least in rails 1.8.6 its not part of the standard lib. Is it part from the ruby 1.9 lib? If not, should i in...
Hello, I'm new to Ruby so forgive me if this is something obvious..
I've made a class like so
class Element
attr_accessor :type
:type_integer
:type_string
end
(this is really just an example, not actual code)
Well, I've read http://stackoverflow.com/questions/75759/enums-in-ruby and I'd prefer to go the Symbols route of having...
I am a front end developer (HTML,CSS,JS & jQuery) I know a bit of PHP. I am trying to grasp what Ruby/Ruby on Rails is.
On http://rubyonrails.org/ it says "Ruby on Rails is an open-source web framework that's optimized for programmer happiness"
In actual, non-dreamy terms, what is special about Ruby/Ruby on Rails, and how can a person...
I am attempting to create a web-based game in Ruby on Rails. I have a model named 'Game', which has a datetime in the database entry that corresponds to a time that I would like the server to call the Game model's update_game function. Depending on the game's settings, this could be every 30 seconds to every 12 hours.
Ruby on Rails ...
Hello. I'm looking for help with converting C++'s custom RLE unpack function to Ruby style.
struct packer_opcap {
unsigned char tlen : 3;
bool tzero : 1;
unsigned char blen : 3;
bool bzero : 1;
};
static void rle_unpack(const unsigned char* in_buf, int in_length, std::vector<unsigned char> &buffer)
{
buffer.clear();...