I am trying to do this
Version.find(:all, :joins=>"JOIN editions ON versions.edition_id=editions.id JOIN products ON editions.product_id=products.id", :select=>"products.name, versions.name AS what")
but ActiveRecord is not respecting the AS keyword... any ideas?
Edit: Since both fields are called "name" they are colliding, so I only...
Hopefully this example will illustrate my point better than simply trying to explain it:
I'm using one of the many jQuery watermark plugins. To attach a watermark to a textbox, the syntax is:
$(document).ready(function(){
$("#item_description").watermark("Description");
});
This works wonderfully if I have a page that already cont...
I have an ActiveRecord model Language, with columns id and short_code (there are other columns, but they are not relevant to this question). I want to create a method that will be given a list of short codes, and return a list of IDs. I do not care about associations, I just need to end up with an array that looks like [1, 2, 3, ...].
M...
Hey guys, my first question here.
I am making a site in RoR and I am inside a multi DB environement. By that, I mean that some of my models are linked to MSSQL tables, and some others are linked to MYSQL tables.
It works well for the most part, but when I use the 'include' option in a find method, I get a very weird mix of SQL. Let me ...
Hello, I just wanted to get some feedback on better ways to model a team/team membership in rails.
I currently have the following:
class User
has_many :teams, :foreign_key => "owner_id" #user owns this team
has_many :memberships #user is a member of these teams
class Team
belongs_to :team_administrator, :class_name => "Use...
I'm trying to get the ActionView-Helper collection_select to take a value that will be preselected in the dropdown-menu.
Neither (:selected in the html-option-hash)
<%= collection_select(:my_object, :my_method, @my_collection, :id, :description_string, {}, {:selected => @my_collection_object.id}) %>
nor (:selected in the option-hash)...
We have a grid control that allows a user to filter text in different fields. A number of these fields might be timestamps, like created_at and updated_at.
Now, a user can do many different types of filters, including >, <, >=, <=, etc. So, a query that comes across from the control might look like:
"created_at > 2009", or "created_at ...
I've added a few modules and dropped them in my /lib directory and I think the lib directory is loaded magically by Rails (unless I loaded the lib directory somewhere early in my project and forgot about it). However, when I run unit tests that require my additional modules, they are not loaded.
Should the lib directory be loaded autom...
You include the modules in classes to extend the class functionality in terms of both adding class methods and instance methods to that particular class.
module M
def self.class_method_from_module
'from class_method_from_module'
end
def instance_method_from_module
'from instance_method_from_module'
end
end
class C
include M
...
I want to display a list of articles in my tag's show view. I'm using the acts as taggable redux plugin in a Rails 2.3.2 and SQLite3 app. I've got as far as the basic example takes me, assigning tags and then displaying a list of them with the article.
Now I want to display a list of articles belonging to a tag but get the following er...
I'm in the process of learning Ruby on Rails and I've set myself the task of putting together a very basic shopping cart system. I have a table items that costs of a price column currently set to integer. I have no problem with inputting the data in cent, but when it comes to displaying the price in th view, well I obviously want it to b...
Hello, does anybody know of any tutorials/resources that discuss integrating Amazon's Mechanical Turk and Rails? (besides those resources that Amazon already provides)
Thanks!
...
I have a rake task I need to run as a daily job on a Windows XP machine. I discovered the Windows "scheduled tasks" control panel. I'm trying to figure out how to get it to run my Rake task.
Two of the fields are "run" (with a browse button) and "start in". I tried to enter rake mycategory:mytask into "run" and my Rails project dir cont...
I have a page which needs to pull content from a database and potentially other sources.
This is how I've structured my ruby on rails application.
/Index - this has three different sections which needs to load in three different types of content. Each one will take different amount of time to return, as such I want to display a loading...
Hi All,
I'm having severe issues with Rails, Javascript, and redirects. Basically I have the "simple" issue of redirecting to a different page if JS is disabled. If JS is enabled, then I add a new item inline immediately -- this works like a charm. However, if JS is disabled I want to redirect to the NEW page of a different controlle...
Part of why I love Rails is that I hate SQL - I think it's more like an assembly language that should be manipulated with higher level tools such as ActiveRecord. I seem to have hit the limits of this approach, however, and I'm out of my depth with the SQL.
I have a complex model with lots of sub-records. I also have a set 30-40 named...
This is a weird one that anyone can repro at home (I think) - I am trying to write a simple service to run searches on Twitter on a service hosted on EC2. Twitter returns me errors 100% of the time when run in ruby, but not in other languages, which would indicate it's not an IP-blocking issue. Here is an example:
admin@ec2-xx-101-152-x...
When I create a SQL Time column I get a pure time, ie. no date. But when I use the Ruby Time class I get a date as well. The problem is when do a 'find' the generated SQL includes a date and I seem to be getting weird results.
The Table
start_date: time
end_time: time
day_of_week: string
ActiveRecord
def self.now_playing
self.fi...
I've got a formbuilder field specifically for doing DateTime using jQuery. What I'd like to do is have the helper able to push content out to my < head > through content_for. Any ideas?
Thanks,
Stefan
...
I have an Order class that has_many :shipments. How can I use Order.find to return all the order objects whose newest shipment was created after a certain time (say, in the last hour)?
...