I have some controller methods I'd like to share. What is the best practice for doing this in ruby on rails? Should I create an abstract class that my controllers extend, or should I create module and add it in to each controller? Below are the controller methods I want to share:
def driving_directions
@address_to = params[:address_to...
I want to install a gem on all my application servers, but gem install requires sudo access - how can I enable sudo only for running this capistrano command?
In other words, I don't wish to use sudo for all my deployment recipes, just when I invoke this command on the command line.
...
I have some integration points where I want to test various responses - where do you think should I store these artifacts in my spec/ directory of my rails application?
...
Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat.
Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do
c:\my_server> java rails_app.jar
and have it run WEBRick or Mongrel wit...
Ruby on Rails does not do multithreaded request-responses very well, or at least, ActiveRecord doesn't.
The notion of only one request-response active at the same time can be a hassle when creating web applications which fork off a shell-command that takes long to finish.
What I'd like are some of your views on these kinds of setups? I...
I have an application I'm writing where I'm allowing the administrators to add aliases for pages, categories, etc, and I would like to use a different controller/action depending on the alias (without redirecting, and I've found that render doesn't actually call the method. I just renders the template). I have tried a catch all route, bu...
I've been wanting to learn Ruby for a long time since there seems to be alot of buzz about it the last couple years. From what I've seen/read there have been a few Ruby'esk things that have been brought over the .NET too.
Should I start with learning the Ruby language and just focus on writing simple command-line apps first? Or, should ...
Hi,
I have a Rails 2.0.2 application running with a postgresql db. The machine will receive data on a TCP port. I already have coded a working ruby multithreaded tcp server to receive the requests, but I need this code to run alongside my Rails app.
So I guess I need to know how to span a new process inside Rails, or how to create a wo...
Rails uses the concept of migrations to deal with model changes using the ActiveRecord API.
CouchDB uses JSON (nested maps and arrays) to represent its model objects.
In working with CouchDB so far, I don't see good ways of recognizing when the document's structure has changed (other than being disciplined as a developer), or for migra...
Background
Normal rails eager-loading of collections works like this:
Person.find(:all, :include=>:companies)
This generates some sql which does
LEFT OUTER JOIN companies ON people.company_id = companies.id
Question
However, I need a custom join (this could also arise if I was using find_by_sql) so I can't use the vanilla :includ...
Ok I followed the steps for setting up ruby and rails on my Vista machine and I am having a problem connecting to the database.
Contents of database.yml
development:
adapter: sqlserver
database: APPS_SETUP
Host: WindowsVT06\SQLEXPRESS
Username: se
Password: paswd
Run rake db:migrate from myapp directory
----------
rake abo...
I use both ruby on rails and Java. I really enjoy using migrations when I am working on a rails project. so I am wondering is there a migrations like tool for Java? If there is no such tool is it a good idea to use migrations as a tool to control a database used by a Java project?
...
I have a backroundrb scheduled task that takes quite a long time to run. However it seems that the process is ending after only 2.5 minutes.
My background.yml file:
:schedules:
:named_worker:
:task_name:
:trigger_args: 0 0 12 * * * *
:data: input_data
I have zero activity on the server when the process is running. (...
I have a rails app that I have serving up XML on an infrequent basis.
This is being run with mongrel and mysql.
I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connection get timed out for inactivity or something like that.
It can be re...
Hi guys,
I'm running a strange problem sending emails. Basicly I'm getting this exception:
ArgumentError (wrong number of arguments (1 for 0)):
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `new'
/usr/lib/ruby/...
Running OS X Leopard an MacBook Pro from Jan. 2008.
I used to run mysql server from a package but then rails started putting a warning that I should install mysql from gem: gem install mysql
It did not work, I got the following error message:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ER...
How do I find the name of the namespace or module 'Foo' in the filter below?
class ApplicationController < ActionController::Base
def get_module_name
@module_name = ???
end
end
class Foo::BarController < ApplicationController
before_filter :get_module_name
end
...
I want to log user's actions in my Ruby on Rails application.
So far, I have a model observer that inserts logs to the database after updates and creates. In order to store which user performed the action that was logged, I require access to the session but that is problematic.
Firstly, it breaks the MVC model. Secondly, techniques ran...
I have heard that it's best not to actually have any html in your helpers; my question is, Why not? And furthermore, if you were trying to generate an html list or something like that, how can I avoid actual tags?
Thanks!
-fREW
...
I've been kicking around Ruby and the rails framework and have been considering recommending to a client-of-a-client that they use it to rebuild their site, which is currently built in very bad ASP classic that will have to be rewritten from the ground up regardless of what technology is used.
One thing I'm missing from my pitch is a li...