I am working on a project where many ActiveRecord models can have a conversation associated with it. Users can discuss just about every aspect of the site. I have two ideas as to how this should be implemented.
1) Use a belongs_to in the asset, not the conversation - conversation will be totally unaware of its asset
class Product< Acti...
I've got a one-to-many relationship from Treatment to Cost. The reason for this is because for invoicing and tax purposes we need to keep a record of changes in price for a treatment. So this is implemented by saying that the cost is equal to the most recent cost entry associated with that treatment.
This feature needs to be completel...
At the moment, I am doing my complex queries by hand so to speak. But I keep encountering problems. For instance.
query = "SELECT histories.candidate_id
FROM histories
WHERE histories.institution_id IN (?)
GROUP BY histories.candidate_id
HAVING COUNT(*)= ?"
cand = [Code.fi...
I'm maintaining a rails 2.1 application that has some unfortunate choices for column names. For instance, an Event has a start and an end date. Instead of using start_at and end_at the original design uses start and end. Of course this leads to
def end
read_attribute(:end) || 1.hour.from_now
end
I'm surprised this even parses...
Like... I want text fields to say stuff like..
password....
and then when the user clicks in them, the text goes away, and allows them to type.
...
I'm using rails' select helper on my page, dynamically populated with Categories on a page showing news articles. Changing the select should refresh the page and show news articles for the selected category. I'm storing the category id in the session. How do I make my select show persist the correct selected value? Currently trying this ...
I want to run this same code for several mailers in an ActionMailer class. How can I achieve it?
...
I recently asked this question and the answer makes alot of sense to me. Now I ponder how those answers hold up in an environment like Rails where there are plugins/gems available like, say, vestal_versions?
If I'm selling widgets and the price and/or description of the item will change over time and Rails is my framework. How would you...
I need to update a model after delayed_job processes a task on it, e.g:
foo.delay.something
After something is done, I need to update the foo object, what is the best way to achieve this? I was thinking in coding a callback on the Delayed::Backend::ActiveRecord::Job class, but there's should be something cleaner and better to do this. ...
Hi all,
Does rails have a way to get JUST the src of an image as a string? I'm trying to embed the image on a third party site in javascript.
This is the general idea (widget.js.erb):
var widgetImage = new Image();
widgetImage.src = "<=% Some groovy ruby code to just get the image src as a string %>"
Any ideas?
...
I have a Deals controller and I have an action called popular. I have added the popular to the routes (as a collection, if it's worth the info) and I want everybody to be able to acess that page.
I'm using CanCan and I have this:
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
alias_action [:...
Guys,
Is there a way to setup a callback in ROR that would trigger at a specific time?
Lets say I'm running a contest that expries at a certain time. Lets say Monday July 28th at 9:00. I'd like to set up an observer that ran a function at Monday July 28th at 9:00. Does rails have a method to do this?
...
In my Rails app, I have a Runs model, a Timesheets model, and an Athletes model. A Run belongs_to an Athlete, and an Athlete has_many Runs. A Run also belongs_to a Timesheet, and a Timesheet has_many Runs.
Timesheet/show/:id lists the runs associated with a particular timesheet, along with the athlete associated with each respective ...
As a new comer to writing front-end views with Rails, I'm a bit confused as to when I should be using rjs templates versus when I should be writing my own JavaScript to handle events/DHTML. Is there some rules you avid Rails developers follow for when something is too complex or not possible with RJS and you just write the JavaScript you...
I have a page where I can view a product, and directly from this page the user can add and remove multiple images associated with the product. I'm using paperclip in a form to upload new file.
Because multiple images can be saved for a product I created an image model belonging to the product model. It's not possible to use the default...
Trying to deploy my rails application but when access through web
I'm getting 500 error saying that
The application spawner server exited unexpectedly: Unexpected end-of-file detected.
Exception class:
PhusionPassenger::Railz::ApplicationSpawner::Error
I googled the whole internet but found only couple of guys who had the s...
Does someone have a complete list of model types that be specified when generating a model scaffolding
e.g.
foo:string
bar:text
baz:boolean
etc...
And what do these types map to in terms of default UI elements? Text field, Text area, radio button, checkbox, etc...
...
I am using the open_id_authentication plugin for login purpose. I am able to integrate the plugin correctly and it works well. I would like to retrieve additional values like the nickname and email of the user, which I am not able to retrieve. I am using the following code but the registration fields are empty . Am I doing something corr...
So where does Rails pick up the environment context (dev, test, prod).
Lets say i am taking my Rails code to a prod server, how do i tell rails to use the prod env file/properties?
...
So this is a newbie rails design question. Lets say I want some of my common functionality to be sitting in a set of helper classes (either as class methods or instance methods).
And I want to use these helper objects inside controller (not view) or even may be a model. can I do that? how? Does it have to be a module or class or can be ...