Hello
I am trying to get the difference in hours for two different Time instances. I get these values from the DB as a :datetime column
How can I do this so that it includes the months and years as well in the calculation while ignoring or rounding the minutes? Can this only be done manually or is there a function to do this?
Thank y...
Are there any issues to consider when using DRb for implementing an in-memory message queue and for synchronizing actions between processes? I heard that it could be unreliable, but haven't found anything on the web that confirms this assertion.
In case it's relevant, these would be processes running with a rails app environment that...
Hello,
I'm starting to code a Rails application to allow users to create and edit forms that other users could then fill in, the data could then be analyzed and re-used. I've already asked other questions on structure etc.
Now, believing that the best code is the code you don't have to write, I was looking for similar, open source, pr...
class Car < ActiveRecord::Base
has_many :passengers, :as => :vehicle
end
class Passenger < ActiveRecord::Base
belongs_to :vehicle, :polymorphic => true
end
class Kid < Passenger
end
Can I use "has_many :kids, :as => :vehicle" in Car class definition?
...
Hi there!
Now I practice deleting characters such as:
input = input.gsub(/<\/?[^>]*>/, '')
and for special characters, example ☻ or :
input = input.gsub('&#', '')
this leaves only numbers, ok. But this only works if the user enters a special character as a code, like this:
™
My question:
How I can delete special characters...
I don't want to add schema.rb to .gitignore, because I want to be able to load a new database schema from that file. However, keeping it checked in is causing all sorts of spurious conflicts that are easily resolved by a fresh db:migrate:reset.
Basically I want a way to:
Keep schema.rb in the repository for deploy-time database setup...
I need to sort an array of ActiveRecord objects by the value in one of the columns but am unsure of how to do this.
Example, I have an Schedule model that has a Duration column. I then have two arrays of Schedule objects OriginalList and NewList. I want to sort each of those lists by Duration. I think that I'm looking for something like...
I'm wondering how many data access should I do in a View when using a MVC framework.
For instance: In my application there is a page that shows a list of all my favorite artists and, for each artist, a list of all songs of that artist.
The question is: Should I pass only the artist list to the View, or should I pass also all the data (a...
Hello
I am running Rails 2.0.2 and am unable to use :dependent => :delete in my AR associations
has_many :items, :dependent => :delete
I am given this error.
The :dependent option expects either :destroy, :delete_all, or :nullify (:delete)
I have be unable to find the documentation for :delete_all to see if it does what I want....
This seems like a really simple question but I haven't seen it answered anywhere.
In rails if you have:
class Article < ActiveRecord::Base
has_many :comments
end
class Comments < ActiveRecord::Base
belongs_to :article
end
Why can't you order the comments with something like this:
@article.comments(:order=>"created_at DESC")...
Is there a realtime apache/php console similar to webrick or mongrel with ruby on rails?
I want to be able to monitor what the heck my server is doing.
edit:
but I don't want to grep the log
Thanks!
...
Now that Google allows Java on App Engine, I'm wondering what effect this has on a choice of web framework for App Engine.
I realize Google provides the webapp
framework which is pretty barebones.
And the .96 version of django that's
available for App Engine is
restrictive.
web2py burns up resources, from what I've heard.
Rails (now a...
I am trying to find a record in the database that has the lowest value of its datetime column. In simpler words, I want to find a record with the earliest time.
I can use minimum to find the lowest value, but that will only return the value itself, and not the whole record.
I suppose I could create another query, but I'm wondering if t...
I'm using Apache with passenger to run a rails app. In my rails app, I have some static content in subdirectories of the public directory. Each subdirectory has an index.html in it.
So, inside the public directory, I have a subdir called 'b' and inside it, is an index.html. So it's like this:
/public/b/index.html
I have links to th...
I am making a rails app and having a ridiculously hard time trying to get the Redbox plugin to work. I'm pretty sure I installed everything correctly and am using it properly. When I use one of the helper methods, it seems to generate javascript properly. For example when I type:
<%= link_to_redbox 'hello', 'test' %>
it generates:
<a...
Say if @news_writers is an array of records. I then want to use @news_writers to find all news items that are written by all the news writers contained in @news_writers.
So I want something like this (but this is syntactically incorrect):
@news = News.find_all_by_role_id(@news_writers.id)
Note that
class Role < ActiveRecord::Base
...
Hi I'm using Alloy's Complex Form Example found here. The example he provides is a two level hierarchy and I'm trying to expand it to four.
He has javascript functions for adding nested items. Can someone show me how to expand for four nested layers?
'.add_nested_item': function(e){
el = Event.findElement(e);
template = eval(el...
Recently I changed a few nested resources in one of my applications to use shallow routing. It's working great and I've been able to simplify my views and controllers.
However, I've been using a path_prefix before:
map.with_options :path_prefix => "blog" do |blog|
blog.resources :posts do |posts|
posts.resources :comments
end
e...
I want to make a section in my site where visitors can upload files (pdfs). How can this be done?
Also, after the pdf is uploaded, I need a link to that file. Rather than using a boring text link, I was thinking of having a thumbnail graphic of the first page of the pdf. Is there a tool out there that does this?
...
I'm new to rails and am trying to work out how to get nested layouts working; I'm assuming they're a bit like .net master pages?
I've followed this guide and I've created an application.erb.html in my layout directory which contains this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1...