This may sound odd but a right answer might save me hours of coding. I have found a ruby-on-rails class (~10 files, ~1000 lines total) that serves a specific purpose (payment gateway integration). However, I am not familiar with ruby at all and need to use that class in a PHP application. I am wondering if there is a program that can per...
I've been learning Python for a while, but the projects I want to do are better suited for Ruby, for example the SAC API for CSS is available in Ruby (and C & Java).
Anyhow, which version of Ruby should I learn right now considering that I'll be building only web apps.
Thanks for your comments and advices.
...
Does a Binding know the variables it stores? Or do I always have to use this in conjunction with local_variables?
...
I am about to finish my script that parses/scrapes website using mechanize&ruby.
I need to port my script to PHP in the future.
My question is
if there is any library available for both ruby and php or
if anybody can recommend any other approach to this?
...
I have two models with a many to many relationship using has_and_belongs_to_many. Like so:
class Competition < ActiveRecord::Base
has_and_belongs_to_many :teams
accepts_nested_attributes_for :teams
end
class Team < ActiveRecord::Base
has_and_belongs_to_many :competitions
accepts_nested_attributes_for :competitions
end
If we a...
Assume, I have the following class:
class MyClass
attr_accessor :vars
def initialize
@vars = []
end
def add_var var
@vars << var
end
end
I want to access inners vars like this:
x = MyClass.new('root')
x.add_var 'test'
x.add_var 'something'
x.add_var Myclass.new('google')
x.google.add_var 'nice'
puts x.test
puts ...
How can I do something like this ? or do i need to use IF all the time?
ar = [["a","b"],["c"],["d","e"]]
x = "b"
case x
when ar[0].include?(x)
puts "do something"
when ar[1].include?(x)
puts "do else"
when ar[2].include?(x)
puts "do a 3rd thing"
end
I'm using ruby 1.8.7
...
Hello,
I have a relationship in which a post belongs to the city which inturn belongs to a state like:
class Post < ActiveRecord::Base
belongs_to :city
end
class City < ActiveRecord::Base
belongs_to :state
end
Now i want to find all the posts along with the their cities and the states to which the belong to. I w...
Hi
I am intermediate in java but as one of the company requirements they are looking for JAVA+RUBY programming language..
Can anybody help how to get started with Ruby I need to get it done in next one month so that I can crack the interview of the company...
I wanna know how does Ruby work like compiler, is it platform independent or...
From a previous post I got Ruby mode working in emacs. This is working great.
http://stackoverflow.com/questions/2078079/setting-up-emacs-file-for-mac-ruby-development
Our company uses 4 spaces for indents though instead of the default 2. I am having difficulty getting this to work.
Here is my .emacs file
(add-to-list 'load-pat...
I have an application where in the layout I have a user_name div which will display different things based on whether or not they are logged in, are an admin, etc. Right now my code is the following:
<% if current_user.role == "admin" %>
<p id="admintxt">You are an admin!</p>
<%= link_to "Edit Profile", edit_user_path(:current...
I have a pretty simple setup. To sum it up here's what I'm doing:
class Movie
include MongoMapper::Document
has_one :setting
end
class Setting
include MongoMapper::EmbeddedDocument
belongs_to :movie
end
What I want to do is to update the setting of a movie in the same form as the movie other information. Therefor I do that :
...
I want to define method like include?(obj) which check existence of obj in array of my class. Is there a way to do this in ruby?
I have Item class
class Item < ActiveRecord::Base
include Comparable
belongs_to :itemable, :polymorphic => true
def <=>(other)
self.itemable.id <=> other.itemable.id
end
...
end
and I...
I'm trying to change an ERB to remove the line
<div id="header"></div>
However, the resulting div tag still appears on the page, even 30 minutes after the fixed file was uploaded to the server. The server is running Ruby 1.8.6 and Rails 2.1.2, and the affected files (two_column.html.erb and three_column.html.erb) were downloaded from...
I have a custom form builder, and one of the reasons for this custom builder is that for every form, I need to include some extra params that I don't want to explicitly put in with hidden field tags in every form I write.
for_for(@foo, :builder => MyBuilder) do |f|
# stuff I shouldn't have to worry about
# this should be put in all ...
Is there an easy ruby or rails command to get a list of all the tests in an application? I use Shoulda primarily, but if there's a ruby solution regardless of test suite that would work too.
...
Is it possible to change the width that prettyprint (require 'pp') uses when formatting output? For example:
"mooth"=>["booth", "month", "mooch", "morth", "mouth", "mowth", "sooth", "tooth"]
"morth"=>["forth",
"mirth",
"month",
"mooth",
"morph",
"mouth",
"mowth",
"north",
"worth"]
The first array is printed inline because it f...
I use TextMate for my Ruby editing, but when printing files, the code isn't syntax highlighted. Are there any good programs for printing out well-formatted color-highlighted Ruby code?
...
Hi all,
I'm very new to web programming (or actually, very old to it, since the last time I messed with the web was HTML 1.1), but now need to deploy a web application quickly. It seems like every time I turn around, there's new acronyms and technologies to learn (JSON, XMLRPC, GWT, Javascript, Rails, etc).
Here's what my app must do:...
I'm not exactly sure how to properly debug this but have tried a few different approaches that have chewed up time, but not solved the problem. At least 4 other people in my office can execute this code on identical machines with the same version of ruby and rubygems installed with no error.
Here is the code that I'm executing:
status ...