In the rails development environment, cache_classes is off so you can modify code under app/ and see changes without restarting the server.
In all environments, though, middleware is only created once. So if I have middleware like this:
class MyMiddleware
def initialize(app)
@app = app
end
def call(env)
env['model'] = M...
All Rails expert sites say not to store ActiveRecords in the Session. However, I have a multiple-field ActiveRecord object that spans several pages. The code I'm trying to clean up used hidden fields to pass the data forward, which seems like a bad idea (user can tamper for one thing). What's the typical, or good, way to divide up a mode...
I upgraded to Snow Leopard using the disc we got at WWDC.
Trying to run some of my rails apps now complains about sql
(in /Users/coneybeare/Projects/Ambiance/ambiance-server)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Importing all sounds in /Users...
In the course of building a rails application to help small hotels' manage bookings, I'm encountering a strange application hang. Building the reservation works fine; adding guests, assigning them to rooms, etc, without issue. However, when the merchant goes to 'confirm' an inquiry, Mongrel hangs me out to dry.
The index page for reserv...
I have an author class:
class Author < ActiveRecord::Base
def to_s
name
end
end
Defining to_s allows me to do puts Author.first, but not puts Author.first.rjust(10):
NoMethodError: undefined method `rjust' for #<Author:0x21eb5d4>
Wouldn't it be better if Ruby automatically tried to_s before the string method in cases like t...
is there any free cheatsheet on ruby refactoring that i can print and put on the wall?
...
I have no idea how I would set up a BerkelyDB database in a Ruby or Rails project.
Does anyone have any experience configuring one, that they could talk about?
Maybe using ActiveRecord or Datamapper?
...
BerkeleyDB is the database equivalent of a Ruby hashtable or a Python dictionary except that you can store multiple values for a single key.
My question is: If you wanted to store a complex datatype in a storage structure like this, how could you go about it?
In a normal relational table, if you want to represent a Person, you create ...
Hi All,
I'm currently developing a Rails app with 4 nested models (as per THIS POST). I've considered using javascript to manage them all on one page. It appears doable (as do many things in Rails), however, it doesn't come highly recommended.
That said, I'm looking to manage via proxy pages. Currently the model structure is as foll...
I would appreciate it if someone could help me understand the difference between using a Yielder in an Enumerator vs. just invoking yield in an Enumerator.
The "Well-grounded Rubyist" suggests that one doesn't "yield from the block" but doesn't explain precisely what's going on.
Thanks
...
This is probably very easy, but I'm having a hard time figuring it out.
I have a partial:
<% for room in @scrape %>
<tr id="page_<%= room.id %>">
<th scope="row" class="<%= cycle("spec", "specalt") -%>"><%=h room.name %></td>
<td class="<%=current_cycle%>"><%=h room.day1 %></td>
<td class="<%=current_cycle%>"><%=h room.da...
I've looked everywhere for an elegant solution. The essential problem seems to be that ActiveRecord attributes that map to database columns are handled completely differently in ActiveRecord::Base than attr_accessor methods.
I would like to do something like:
model.attribute_names.each do |name|
# do stuff
end
in a way that also i...
Hello, im a beginner with DataMapper ORM, so i have question about complex querying.
First, here is simplified data objects:
class User
property :id, Serial
property :login, String
has n, :actions
end
class Item
property :id, Serial
property :title
has n, :actions
has n, :users, :through => :actions
end
...
I need a script or cmd line tool get an mp3 length in milliseconds. The files are 64 kbits mono cbr encoded with lame.
(I looked for a libmad for ruby, my language of choice, but found nothing noteworthy...)
...
Ruby doesn't seem to have a facility for defining a protected/private block like so:
protected do
def method
end
end
This would be nice compared to
protected
def method
end
public
where you might forget to "public" after the protected methods.
It seems possible to implement this using metaprogramming. Any ideas how?
...
On average, how long does it take for Debian to package new versions of rubygem packages (assume the package doesn't have C code) into their package system? Is it more like weeks, months or years?
...
Hi guys,
I'm using ruby openid compliant library so I can be an openid consumer, I got the sample and when I try to start-up the service, it show errors like
/var/lib/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in `ensure_session_key': A key is required to write a cookie containing the session data...
Can you explain me its meaning or give the link to the API page (which I couldn't find)?
...
I have a farm of several physical servers each running a large number of Ruby "workers" (daemon-like processes) and I'd like to be able to monitor the health and progress of these processes from a central location, perhaps with historical graphing like Cacti provides. What's the simplest preferably-open-standard protocol for doing somet...
Hey guys,
So I generate my scaffold in rails, and it creates the usual CRUD files. In my View, I copy over the form found in new.html.erb and paste it over at index.html.erb, so I can create a new record from my index. When I do that, I get the following error consistently, no matter what I do.
Called id for nil, which would mistaken...