ruby-on-rails

Does Grails have anything like acts_as_tree in Rails?

I am just getting into Grails having had some experience with Rails, and I am looking at creating an app where I have to primarily persist tree structures (and query them as well). Rails has several very useful acts_as helpers for representing domain objects as different data structures, such as acts_as_tree. From my initial reading it ...

Using Rails, how can I set my primary key to not be an integer-typed column?

I'm using Rails migrations to manage a database schema, and I'm creating a simple table where I'd like to use a non-integer value as the primary key (in particular, a string). To abstract away from my problem, let's say there's a table employees where employees are identified by an alphanumeric string, e.g. "134SNW". I've tried creating...

Using ActiveRecord belongs_to with two keys

Hi, I have two ActiveRecord models with a hasMany / belongsTo association: class User < ActiveRecord::Base has_many :letters end class Letter < ActiveRecord::Base belongs_to :user end The User model has a revision_number attribute, to which I would like to scope the belongs_to association, so the letter is associated to a User b...

Has namedspaced routing changed in Rails 2.3?

I have an admin namespace which gives me the usual routes such as admin_projects and admin_project, however they are not behaving in the usual way. This is my first Rails 2.3 project so maybe related I can't find any info via Google however. map.namespace(:admin) do |admin| admin.resources :projects end The strange thing is for a gi...

ruby on rails if statement with boolean on index.html.erb page

Maybe I'm missing something simple but I can't figure out after some time looking at this. I want to check if a boolean is true in a database on a form, if it is display a up arrow, if not down arrow. I have this <% for probe in @probes %> <tr id="<%= cycle('list-line-odd', 'list-line-even') %>"> <td> <%= if probe.on...

Using Ruby-on-Rails, Sphinx or UltraSphinx and an HTML source (not a database)

The documentation states for sphinx-0.9.9-rc2: The data to be indexed can generally come from very different sources: SQL databases, plain text files, HTML files, mailboxes, and so on. However, I can't find any documentation on setting up a a source besides SQL. The config file doesn't seem to indicate that the source can be anything ...

Rails - Invalid Authenticity Token After Deploy

Hello, We're using EngineYard Cloud to deploy our Ruby on Rails application. We are running Rails v2.3.3. EngineYard Cloud deploys to AWS instances in a manner similar to Capistrano. After each deploy, we're running into Invalid Authenticity Token errors. Specifically, any user that has previously visited our application and then vi...

How do I generate RDOC for (all of) Rails?

I can do sudo gem rdoc activerecord --no-ri and sudo gem rdoc actionpack --no-ri both of which give me good docs. But sudo gem rdoc rails --no-ri gives me pretty much nothing, as the Rails gem itself is really just a holder for the others. How can I generate the equivalent of http://api.rubyonrails.org/? ...

Code works but test fails

I have a test that's failing even though the operation actually works when I test it in the browser. Something wrong with my test, looks like. I'm using Shoulda and fixtures. require 'test_helper' class AddressesControllerTest < ActionController::TestCase context 'on PUT to :update' do setup do put(:update, { :id...

How are Migration Scripts applied in Rails 2.1 and higher?

I'm not a Rails developer (currently) so please forgive my ignorance on this. One thing I've always liked about Rails is migrations and how it fills a need that's common across all languages and platforms. With that said, I am curious to understand what a certain scenario would result with the changes made in 2.1. Rails 2.1 and higher...

Multi-level Complex Rails Forms

Hi, I'm trying to create a multi-level ajax form on my rails app that can add/remove fields associated with a new object in a form when a button is clicked. However, I need to have multiple levels to this form (i.e. if someone adds a "Meal" object, there must also be a button inside the created "Meal" form for "Add a food".) I follow...

Rails nested routing to html id

given a blog style application: #models class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end #routes.rb map.resources :posts do |posts| posts.resources :comments end how do I generate routes to an id on a page? Examples /posts/1#comments /posts/2#comment14 ...

How do I make an image link tag using haml in Rails?

I have something like this in application.html.haml: #header = image_tag("header.jpg") How do I make that link to www.google.com, for example? Thanks ...

Double join with habtm in ActiveRecord

I have a weird situation involving the need of a double inner join. I have tried the query I need, I just don't know how to make rails do it. The Data Account (has_many :sites) Site (habtm :users, belongs_to :account) User (habtm :sites) Ignore that they are habtm or whatever, I can make them habtm or has_many :through. I want to b...

Is it possible to verify the domain that a cookie was set for using Rails integration tests?

I'm using the following technique to set a wild-card cookie for our domain: cookies['root_domain_flash_warning'] = { 'value' => 'mistakes have been made!', 'domain' => ".#{APP_DOMAIN}", 'expires' => 2.minutes.from_now } Which seems to work handily. Unfortunately I can't seem to look up anything but the value associated with the...

Is there a rails plugin for uploading bulk items to eBay?

Hi, I made a rails app that generates HTML code for eBay product description. Currently my client copies the HTML code to the eBay site manually. I wonder if I can automate the process. Of course, I don't want to start from scratch. Is there any eBay API plugin for that? Thanks. Sam ...

using both :url and :function on observe_form

Is there a way to generate both a Javascript function call and an Ajax call in the same observe_form tag? For example, something like this: <%= observe_form 'user_filter_form', :url => { :action => :process }, :function => :fix_fields %> Thanks!! ...

how can I find out the current route in rails?

I need to know the current route in a filter in rails.. how can I find out? I'm doing REST resources, and no named routes ...

Building a user-customized layout with rails

I'm building a site that has user defined pages that are composed of a set of widgets. The widgets are fairly basic, similar to what you'd find in Blogger. Some widgets are for data collection/formatting presentation with basic structure (lists, tables) and others provide more complex functionality (blog, photo albums, etc) I want to a...

Learning Ruby on Rails with Pragmatic book

I only have a background knowledge of java and C, and a bit of unix (learned from the first year Comp Sci) and i do know bit about HTML/CSS... anyways so i've started using the book and the book said that we don't need to know html or ruby or css and that book would be kinda teaching all that as we go along.. And i'm at the part where w...