I've been using JSON to handle AJAX functionality in my rails applications ever since I heard about it, because using RJS/rendering HTML "felt" wrong because it violated MVC. The first AJAX-heavy project I worked on ended up with 20-30 controller actions tied directly to specific UI-behaviors and my view code spread over controller acti...
I am using Rails 2.3.5 .
This is a standard case. Tables are: users, comments, user_comments . I need to find all the users who have status 'active' and have posted at least one comment.
I know comments table can have foreign key but this is a contrived example. There are two users in the table. There are two comments. Both the commen...
Hey folks,
I'm just learning rails and I've run into a bit of a snag. Let me start with a simple breakdown of my application - it's a cookbook (of sorts)
Recipes have one or more ingredients (tuna, spleens, etc)
Ingredients have one unit (ounces, pounds, etc)
Units are pulled from a lookup table
Here's a screenshot to help clarify t...
Hi, I have a user stored in a session which I would like to add as the owner of a comment. Rather than having a hidden field for user_id, I would like to add the user before the comment is saved in the controller.
What would be the best way to do this?
@comment = @post.comments.create(params[:comment])
Thanks.
...
I'm starting to integrate our Rails-based app with other, external APIs. We're going to start with mailing list services (probably Mad Mimi or Campaign Monitor).
I'd just like to know if anyone has best/preferred practices for approaching simple integration, error checking and the like.
Do you put API functions in model callbacks? Is ...
I need to load data for my Rails application from multiple providers (REST/SOAP based XML feeds) into the database on a recurring basis. I have written a set of Rake tasks which are kicked off by whenever-generated cron jobs. Each task hits the partner feed endpoint, parses the feed and loads it into the database.
Instead of writing Rak...
I'm trying to create a model for a comic book which has 1 writer and 1 artist. These are both instances of a Person. However how do I show this in my migration?
class CreateComics < ActiveRecord::Migration
def self.up
create_table :comics do |t|
t.column :name, :string
t.column :writer_id, :integer, :null => ...
My Song model has a lyrics text attribute. Since new lines are \n-separated in my lyrics, I often find myself doing this in my views to make the lyrics HTML-friendly:
@song.lyrics.strip.gsub(/\n/, "\n<br />")
I'm repeating the gsub logic all over my application, and, worse still, I can't change the format in which I store my lyrics wi...
Hi all,
I'm new to the whole push notifications thing, and was wondering if somebody could walk me through the process of getting a simple application up and running. I currently rent a server that I use to serve my website that runs cPanel X.
How would I go about setting up the service? What software do I need to install on the serve...
I have an XML feed I am pulling down and parsing in my Rails app. I started to implement it as a library in lib/ but it seemed more logical to me to treat it as a model. For convenience I am treating it as an ActiveRecord model. A requirement is that it is compatible with mislav's will_paginate plugin, although that is where I am havi...
Greetings,
How do I turn off ETag(s) in Ruby on Rails v2.3.5
When I do a direct request to to the RoR/Mongrel an ETag header is present.
TIA,
-daniel
...
I have a basic two tiered model structure: Articles -> Comments with one Article having many comments.
What is the best way to add a "Add a comment" form to the bottom of the Articles show page?
nested_attributes is overkill as I don't want to be able to edit all of the comments on the page, just to add one more.
Is the best way even ...
When you call javascript_include_tag :defaults you usually get: prototype.js, effects.js, dragdrop.js, and controls.js.
These are stored in a constant in ActionView::Helpers::AssetTagHelper called 'JAVASCRIPT_DEFAULT_SOURCES`. My application uses jQuery, so I want to replace the Prototype references with something more useful.
I added ...
I am coming from a Java background where we write our own queries or stored procedures and deal directly with low level database stuff.
I am going though AWDR 3rd edition book and can not grasp the joins concept.
Can someone share a resource they used when first coming to Rails?
Let's say I want a Customer table and Order table. a ...
Before I post this as a bug to the rails team, I wanted to see if I'm doing something wrong that may be causing this behavior. Specifically, the :autosave property of has_many associations doesn't seem to be working as per the docs.
For reference, here is the most current API documentation:
http://api.rubyonrails.org/classes/Acti … ati...
I'm working on a application that requires a feature-rich media view, including images, videos, and smooth sequencing based on capture time. The backend is currently written in Rails.
What's currently the best, most mature option for implementing RIAs with Rails on the backend? I've looked at Flex, Laszlo, and ExtJS. ExtJS is interestin...
My "link_to" and "url_for" etc. methods are generating paths in the pattern of ":controller/:id/:action", instead of ":controller/:action:/:id" - in other words my "action" and "id" fields in the url are getting swapped.
I've narrowed it down to these generated links through doing some route debugging, however, I don't quite understand ...
After upgrading to ruby 1.9 we began to notice pages failing to render from the rails template renderer when a user used a non-ASCII character. Specifically "é". I was able to resolve this issue on one of our staging servers, but I have not been able to reproduce the fix on our production server.
The fix that seemed to work the first ti...
Some functionality in my app works differently depending on the client's IP address. Is there a way to test that in Rails functional tests? I'm using Test::Unit and Shoulda.
...
I am building a gallery index of Items in which some Items have photos and others do not.
I would like to grab all of the Items (or a subset with will_paginate) and sort them first by the items with a photo (attached via Paperclip) and then by the record creation date.
I need a binary "has attachment" type status for the first part. Do...