Long time lurker, first time poster. I'm a self-taught hacker that learned Ruby on Rails to start. At work I've been allowed to work on a web app--the only catch is I have to use ASP.NET. This technology choice is mandated, as much as I'd prefer to use Rails.
There's dozens of "Rails for .NET/PHP/Java Developers" books and blog posts bu...
I looked at subdomain-fu and it looks pretty easy to route all non-www and non-'' subdomain requests to a single controller.
But I also, need to send all external domains that are CNAME'd to my domain to the same controller. I have done a lot of searching and I can't find anything.
Summarized, if it is a subdomain on my domain it goes...
I have a question regarding mod_passenger and Singleton classes (rails 2.3.5 and ruby 1.9.1).
In my aplication, I have a Singleton class that implements a thread pool (thread safe).
Also there is controller to manage all the threads (kill and start them). This controller uses the previous singleton class to do the actions over the thre...
Good afternoon. I am a user experience designer, proficient in XHTML and CSS. I have dabbled with some PHP and JavaScript but by no means am I comfortable with them.
My main goal is to develop OS X and iPhone software. I have been given advice on those topics, but in I am struggling with Object Oriented programming.
Books that I have ...
I have a web app which has a global layout file (application.html.erb).
When I encounter a 404 or 500 error the corresponding error page is rendered inside the layout file.
I want to prevent this from happening and render outside the layout but I can't figure out where to put the render :layout => false call. Can anyone help?
...
Is there a way to create custom deprecation notices for methods and/or associations in my application that I plan on removing and want to log their usage? I have a relationship in one of my models that I don't want to use moving forward and plan to refactor the code at a later time. I would like to create a notice in my development log e...
How would i go about to receive mails in a Ruby on Rails application without going through a mail server like PostFix or to fetch them by pop3 etc.
What i was to do is to catch all mails sent to @mydomain.com and just do something with them in my application. I don't need to store the mails or anything like that.
Is this posible?
...
I'm tempted to say yes.
A contrived example, using has_many :through and polymorphs:
class Person < ActiveRecord::Base
has_many :clubs, :through => :memberships
has_many :gyms, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :member, :polymorphic => true
end
class Club < ActiveRecord::Base
has_ma...
I'm working on a Rails app that accepts file uploads and where users can modify these files later. For example, they can change the text file contents or perform basic manipulations on images such as resizing, cropping, rotating etc.
At the moment the files are stored on the same server where Apache is running with Passenger to serve al...
I can't find very good intros to specific callbacks in rails.
Basically I'm dealing with two models:
Order
Item, (nested in Order form)
I'm using the before_update model to do some basic math:
class Order < ActiveRecord::Base
accepts_nested_attributes_for :line_items
before_update :do_math
protected
def do_math
...
I've got some javascript that needs to load a rails partial - I'd prefer not to repeat the partial's HTML in the javascript file.
Is there a way to make this partial accessible via the browser url so JS can load it?
partial location:
shared/_search.html.erb
I would like to grab the view html with something like this:
example.com...
In my application you:
Have an admin user that signs on and that user has a role (separate model), then I use the declarative_authorization plugin to give access to certain areas.
That admin user can also register new users in the system, when they do this (using Authlogic) they fill out a nested form that includes that new users' ro...
I'm trying to build a rake utility that will update my database every so often.
This is the code I have so far:
namespace :utils do
# utils:update_ip
# Downloads the file frim <url> to the temp folder then unzips it in <file_path>
# Then updates the database.
desc "Update ip-to-country database"
task :update_ip => :environm...
I am using the Ruby AMQP Carrot library and I am trying to talk to a test RabbitMQ server on a virtual machine. The AMQP port is open on the machine but I can't get Carrot to establish an external connection. I have tried the following:
Carrot.queue('message', :durable => true, :server => '192.168.162.176')
Carrot.queue('messa...
Where is the best place initialize a Singleton in Rails?
I am using the Carrot AMQP library in a Ruby on Rails app and I only want to initial the settings once and not on every task that is generated.
I currently have it in my environment.rb and it seems to work but I am not entirely sure this is the best place.
Is having Carrot initi...
I'm looking to add tagging to an application which I'm currently building.
Basically it's a simple quiz system and I want admins who enter the quiz questions to be able to tag them appropriately. These tags will then be used to make sure the correct quiz is generated for the correct user type and also for reporting purposes.
I looked a...
I have a class like this
class Foo
attr_accessor :name
end
f = Foo.new
f.name = "bar"
and I would like it to respond to the following method chain with the name attribute so that it interfaces with another object
f.baz.name == f.name
Is there an easy way to return this?
...
class User < ActiveRecord::Base
has_one :location, :dependent => :destroy, :as => :locatable
has_one :ideal_location, :dependent => :destroy, :as => :locatable
has_one :birthplace, :dependent => :destroy, :as => :locatable
end
class Location < ActiveRecord::Base
belongs_to :locatable, :polymorphic => true
end
class IdealLocatio...
I'm using Authlogic and I would like to implement Basic HTTP Authentication in my controller so I could define which action requires authentication.
I know how to do Basic HTTP Authentication authenticate_or_request_with_http_basic an before_filter, but I would like to here from other how to implement it with Authlogic plugin.
class I...
I'm using Ruby on Rails and I'm storing business hours like this:
CREATE TABLE "business_hours" (
"id" integer NOT NULL PRIMARY KEY,
"business_id" integer NOT NULL FOREIGN KEY REFERENCES "businesses",
"day" integer NOT NULL,
"open_time" time,
"close_time" time)
(which came from the thread at:
http://stackoverflow.com/questions/10...