I have a migration in Rails that inserts a record into the database. The Category model depends on this record. Since RSpec clears the database before each example, this record is lost and furthermore never seems to be created since RSpec does not seem to generate the database from migrations. What is the best way to create/recreate thi...
Does anybody know any plugin, that can show line numbers for SQL queries in Rails logs? Something like this:
User Load (0.003154) SELECT * FROM `users` WHERE (`users`.`id` = 1) - (user.rb, line 24)
Thanks!
...
I want to explicitly call a view from my controller.
Right now I have:
def some_action
.. do something ...
respond_to do |format|
format.xml
end
end
... then it calls my some_action.xml.builder view. How can I call some other view? Is there a parameter in respond_to I'm missing?
Thanks,
JP
...
I'm trying to install RSpec as a gem after having it installed as a plugin. I've gone ahead and followed the directions found here http://github.com/dchelimsky/rspec-rails/wikis for the section titled rspec and rspec-rails gems. When I run ruby script/generate rspec, I get the error Couldn't find 'rspec' generator. Do only the plugins...
I have a rails template (.rhtml file) generating a Javascript object. It looks something like the following:
var volumes = {
<% for volume in @volumes %>
<%= volume.id %> : <%= volume.data %>
<%= ',' unless volume === @volumes.last %>
<% end %>
};
Note the unless statement modifier to suppress printing the comma after the...
I recently had to extend the aasm states for the latest version of restful_authentication (github) in one of my apps. I removed the "include Authorization::AasmRoles", copied the existing states and events from the plugin and made the changes necessary to support an additional "published" state on my account model.
Does anyone have a cl...
Just as an example, if I have a Book model and a BooksController, autotest, part of the ZenTest suite will pick up the association between the two and load test/unit/book_test.rb and test/functional/books_controller_test.rb into the test suite. On the other hand, if I have a Story model and a StoriesController, autotest refuse to "notice...
As title.
ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper' to require File.dirname(__FILE__) + '/../test_helper'. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get around it.
...
Is anyone aware of any gems, tutorials, or solutions enabling a user to sign in to a website at one domain and automatically given access to other partner domains in the same session?
I have two rails apps running, let's call them App-A and App-B. App-A has a database associated with it, powering the registration and login at App-A.com...
I just picked up Agile Web Development with Rails 3rd Ed., and I'm going thru the Depot Application chapters, and I have a question about Product/Item options-
If I wanted to modify the product catalog and store so that products could have options (size, color, whatever), where/how would I do that?
Let's say I'm selling t-shirts, and t...
Running Mongrel 1.1.5 on Rails 2.1.2 using PostgreSQL 8.3 via ruby-pg 0.7.9 on OS X 10.4 server...
Added restful_authentication and exception_notification, the latter of which appears to be doing me no good when Mongrel simply dies with "Illegal instruction" every time I select /RESOURCE_NAME/new.
Doesn't matter what resource.
In deve...
Rails is now making multi-threaded applications possible, but it doesn't sound like it applies in every situation (for instance, if you're using Mongrel, it doesn't sound like this affects you at all).
When can you multi-thread your Rails application?
This article gives some more information about multi-threading pitfalls.
...
I want to be able to compare Dates and Times in Rails without always having to call the to_time or to_date method. So I wrote the following code:
class Date
def ==(other)
if other.kind_of?(Time)
self.to_time == other
else
super(other)
end
end
end
I know there's an easy way to write this so that I can make t...
I have a type ahead text field, and when the user hits "Enter" I want to make an ajax call and not submit the form at the same time. My html looks like this:
<input id="drug_name" class="drugs_field" type="text" size="30" onkeypress="handleKeyPress(event,this.form); return false;" name="drug[name]" autocomplete="off"/>
<div id="drug_nam...
I'm working on a Rails web application, and it's currently being used by some 20 users.
Some parts of the application are only accessible by some users, so we already have a basic authorization framework in place, which I implemented using the acts_as_authenticated plugin.
The users' privileges depend on which department they work in, ...
Given a model
class BaseModel < ActiveRecord::Base
validates_presence_of :parent_id
before_save :frobnicate_widgets
end
and a derived model (the underlying database table has a type field - this is simple rails STI)
class DerivedModel < BaseModel
end
DerivedModel will in good OO fashion inherit all the behaviour from BaseModel,...
I came in this morning, fired up my app in the same way as usual, and started getting this error. Since then, I have been down every road I can conceive - to the point of removing and reinstalling every piece of ruby/rails software on my machine, including mysql. I have stripped my application down to just the following.
require 'ruby...
My shared host did not provide git, so I built and installed it into ~/bin.
When I ran it, I got the following error on most commands, although they were successful.
stdin: is not a tty
I can solve that problem by adding:
default_run_options[:pty] = true
to my deploy.rb, but then I get this error, which blocks deployment:...
Suppose the following data schema:
Usage
======
client_id
resource
type
amount
Billing
======
client_id
usage_resource
usage_type
rate
In this example, suppose I have multiple resources, each of which can be used in many ways. For example, one resource is a widget. Widgets can be fooed and they can be bared. Gizmos can also be foo...
I've used straight Mongrel, I've used Mongrel clusters behind Apache, I've looked at Thin, and I'm becoming very intrigued by Passenger. I've looked at Nginx, too. I've looked at MRI, Ruby Enterprise Edition, Rubinius, and JRuby. There are a lot of options, each claiming to be the new holy grail.
What is the best option out there for a ...