I need to do something like this
class User < ActiveRecord::Base
has_many :abuse_reports
end
class AbuseReport < ActiveRecord::Base
belongs_to :abuser, :class_name => 'User', :foreign_key => 'abuser_id'
belongs_to :game
end
class Game < ActiveRecord::Base
has_many :abuse_reports
end
@top_abusers = User.page(params[:page],
...
What's a good book for learning Ruby?
...
I've got a multidimensional array:
foo = [["a","b","c"], ["d", "e", "f"], ["g", "h", "i"]]
Now I need to ruturn the "coordinates" of "f", which should be (1,2). How can I do this without knowing which "row" "f" is in? I've been trying to use the index method, but this only works when I tell it where to look, i.e.
foo[1].index("f") #...
Hi, since I updated ruby using Mac Ports (on Leopard) I have got several problems and I also had to reinstall gems. Now when I run Mongrel I keep getting the error "Missing these required gems" followed by the list of gems that I required in environment.rb but that gems seems to be correctly installed as I see running gem list.
I think t...
(can you tell I'm learning Ruby today? :))
I want to determine if the multidimensional array I'm working with is a 'rectangle'--i.e., the rows are the same size. Here's what I'm doing, which works but feels clunky.
if @myArray[0].size != @myArray[[email protected]].size
raise "This array is not a rectangle."
end
Basically, I'm check...
hi Guys,
I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the FUTURE...
I've been trying to get the latest version of the DNSSD plugin to work with Ruby 1.9.1 but ran into a few problems. I've outlined the steps I have taken so far, maybe someone here will be able to figure out what else is going wrong.
Tried installing the current version, using: sudo gem19 install dnssd Gem install failed citing htons co...
If you have a layout that has in a menu which gets its menu items from a database. Where is the recommended place in a Rails application to place that call and assigns it to the instance variable that the layout uses?
1. @menuitems # exists in application.html.erb
2. @menuitems = MenuItem.find(:all) # code exists somewhere (where should...
require 'tk'
root = TkRoot.new { title "Hello world" }
TkLabel.new(root) do
text 'Hello world!'
end
Tk.mainloop
Where can i download Ruby TK? i googled but didnt find it.
...
I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ruby.
Which one ...
Is there a good guide or tutorial for writing GNOME applets with Ruby?
...
I feel a little bit kind of confused — for about 24 hours I have been thinking which group broadcasting technology to use in my project.
Basically, what I need is:
create groups (by some backend process)
broadcast messages by any client (1:N, N:N)
(potentially) direct messages (1:1)
(important) authenticate/authorize clients with my o...
This is has been bugging me for quite some time.
>> nil.id
(irb):2: warning: Object#id will be deprecated; use Object#object_id
=> 4
Why would nil.id be 4? (or nil.object_id if you want to be picky about deprecations)
...
I'd like to implement a Rails User model that has a DB column called password. I want to make it so that when I call...
user_instance.password = 'cleartext'
the method hashes the cleartext before setting it on the instance like so:
Digest::SHA1.hexdigest(cleartext)
I've tried using a callback, but the problem is that is hashes the ...
Hello,
I'm looking for a better way to merge variables in to a string, in Ruby.
For example if the string is something like:
"The animal action the *second_animal*"
And i have variables for Animal, Action and Second Animal, what is the prefered way to put those variables in to the string?
Thanks
James
...
I'm looking for a blogging tool with some light CMS features in Ruby on Rails. I mainly want something simple, but configurable. I have no need for page snippets, etc. Just your basic main blog, very good (and easy) theme support, some nice sidebar stuff, a few static pages and MetaWeblog API support.
I'm thinking of either using Mephis...
Anybody have experience with Rails workflow plugins? Route/OpenWFEru.
I am looking for CMS type workflow with states like edit, submit, approve, rollback, based on roles. Is this plugin overkill? Would I be better off just doing the same thing with a state machine (AASM) and acts as auditable/acts as versioned?
...
My aim is to create nested resources via one REST request. The REST requests is represented via a XML document. That works fine for single resources but I could not manage it for nested ones. OK I'll give you a little example next.
First create a new rails project
rails forrest
Next we generate the scaffolds of two resources, the tre...
I am using the fine paperclip plugin for rails. Everything is nice so far, users can upload images.
Now i want an extra step before my model is saved, asking for confirmation by the uploader that the image looks right.
Is this possible to do with paperclip? If so, how?
...
I plan to create a method that would format a Time in a specific way (specialized formatting in Russian).
I would like to reuse this helper method in multiple models, controllers and possibly views. Also I would like to call this helper method on instance of Time class like follows:
t=Time.now
t.my_super_shiny_helper
Question: where ...