I've been playing around with the Liquid templating engine this weekend, and I wonder if the following is possible.
Say I have a latest_posts method in a Blog model, which I can pass an integer to to get the latest N posts. Is it possible to use that method in a liquid template?
For example:
class Blog
has_many :posts
def latest...
i have this snippet that i want to access from a controller or a model but i dont know what file to put it in
def cost_to_f(string)
string.gsub(/[\$,]/, '').to_f
end
I tried application controller and application helper and no luck on either
any suggestions
...
I need to have a many to many relationship for products and categories
so i have
class Category < ActiveRecord::Base
has_many :categorizations
has_many :products, :through => :categorizations
end
class Product < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
end
the structure ...
I have a strange problem with sinatra...
In my app the login form is checking with AJAX live whether a nickname is already taken or free... This works fine 90% of the time... But sometimes, randomly, I get no response from the given route anymore... in the console log all new requests to this route are missing as if I haven't sent anyth...
My linux powered laptop still has a dail-up modem.
Is it possible to interface with the phone line through my modem.
Using bash or ruby, ( or something else, if I really have to) I would like to record and maybe even and make and receive calls.
Can this be done? and if so where do I start?
...
I have mongo_mapper set up like so:
class Person
include MongoMapper::Document
many :pets
end
class Pet
include MongoMapper::EmbeddedDocument
key :animal, String
key :name, String
key :colour, String
end
# Create a person
me = Person.new
# Add pets to the person
me.pets << Pet.new(:animal => 'dog',:name => 'Mr. Woofs', ...
That's all. It should be very nice to share the same libs on the client and on the server or not? Are JS VMs like HotRuby (http://hotruby.yukoba.jp/) a "real world" alternative or just a toy?
PS: if I ask it is because I'd like know it, please don't close this question but just share your opinion.
I'm not interested in programming lan...
I am trying to write a program in Ruby that can send a email to a phone. Outside of the program, I am able to do this by sending an email to [email protected] or any other carrier in my Apple Mail client, and it worked fine; it sends a text message to the targeted phone, but when I tried to use a Ruby API (I forget the name), that u...
I have a .html.erb file, with some javascript in it. I would like to do something like this:
var stuff = '<div><%= @ruby_var.title %></div>'
What is the best way to do this? I may be totally off... Thanks.
...
What does the ::MyClass/MyModule scope operator do in Ruby, what is its purpose?
...
Here's the stack: Sproutcore 1.0.1046. Ruby 1.9.1, in RVM. Thin 1.2.7. Thor 0.13.8. Rack 1.2.1. Eventmachine 0.12.10. Erubis 2.6.6.
When I start the sc-server on any application, my first request to this server produces this in the console log:
ArgumentError: invalid byte sequence in US-ASCII
...followed by this stack trace. (I've li...
hello sir,
i am autpmating a web site that have different function page.
i am making differnt modules for each function.
the problem is that i have a login page Login.rb
that has the below code :-
$IE = Watir::IE.new_process
module Login
def Login.login(url)
$IE.goto("url")
sleep (4)
$IE.maximize
#$IE.span(:class =...
Hi, I am working on a Project Euler question. But it take quite a long time (30 Minutes last time) for my PC to get the answer.
When doing time command on my Linux PC. I get result as this:
real 1m42.417s
user 0m18.204s
sys 1m24.026s
This is a time based on much smaller dataset than the question asked.
So my question is, is...
I have done a few projects using Ruby on Rails. I am going to use JRuby on Rails and hosting it on GAE. In that case what are the stuff that I need to know while developing JRuby apps. I read that
JRuby has the same syntax
I can access Java libraries
JRuby does not have access to some gems/plugins
JRuby app would take some time to load...
Hi,
I am faced with an issue in Ruby on Rails. I am looking to convert a string of format Tue, 10 Aug 2010 01:20:19 -0400 (EDT) to a date object.
Is there anyway i could do this.
Here is what I've looked and tried at the following with no luck:
Date.strptime(updated,"%a, %d %m %Y %H:%M:%S %Z")
Chronic Parser
Ruby: convert string to ...
Using shoulda with unit/test I have a context which requires one test to pass before the others are even tried.
Is there a method I can invoke which will fail all following tests in the current context? Or not even run them?
I'm imagining something like:
context "My thing" do
setup do
my_variable = false
end
should "have my...
I am integrating facebook connect with my application which uses authlogic, facebooker, and the authlogic_facebook_connect plugin. After I log in with facebook, I get redirected to the front page of the site (as per my code) - but the page never loads! - it hangs.
Looking at the development log, I see that something is continuously tryin...
This is my common model which has no table.
class CommonActiveRecord < ActiveRecord::Base
self.abstract_class = true
def before_validation
set_blank_attributes_to_nil(@attributes)
end
end
My other models look like this ..
class BalanceName < CommonActiveRecord
def before_validation
super
end
end
I want to fet...
edit: this problem only happens sometimes
This only appears to happen when I run the test from within TextMate (even when I specify the ruby to run it from by hand with a shebang). If I run it from the terminal then everything is peachy…
Here's some code:
require 'test/unit'
require 'shoulda'
class TestingTest < Test::Unit::TestCas...
Does someone know of a good ruby testing library for generating English (or maybe also those Latin "lorem ipsum") words? Another nice thing would be to specify some additional options (e.g. the word length, only use names). Does such a thing exist?
...