ruby-on-rails

Best redirect code 3xx

Hi all, users can sign up to my site and get a standard url (username.teamgeisthq.com) from where they can access their content. They can also get a cleaner domain name like www.username.nl (same as username.teamgeisthq.com) to access their information. Google tells me that it s bad to have 2 urls pointing to the same content. i still ...

acts_as_taggable_on with finders...

I would like to use acts_as_taggable_on to do a auto suggest style tagging similar to stackoverflow below... that or facebook. But I'm unsure looking thru the rdocs what methods to use to pull all the various tags from a giving model. Article.tag_counts_on(:tags) That gives me all the tags... but i'd like to do something more advance...

double accepts_nested_attributes_for

does anyone know if it is possible to do a double nested form for. so that i could upload images to a set from an article form. e.g. Article has_many :image_sets ImageSet belongs_to :article has_many :images Image belongs_to :image_set ...

Capitalize only first character of string and leave others alone? (Rails)

Hi, I'm trying to get Rails to capitalize the first character of a string, and leave all the others the way they are. I'm running into a problem where "i'm from New York" gets turned into "I'm from new york." What method would I use to select the first character? Thanks EDIT: I tried to implement what macek suggested, but I'm getti...

Displaying posts for a passed parameter problem - Ruby on Rails

I have built a blog application using Ruby on Rails. In the application I have posts and tags. Post has_many :tags and Tag belongs_to :post. In the /views/posts/index.html view I want to display two things. First is a listing of all posts displayed 'created_at DESC' and then in the side bar I am wanting to reference my Tags table, grou...

Custom Content-Type for File in Rails 'public' Folder

For assets stored in the 'public' folder of a ruby-on-rails application is it possible to change the 'Content-Type' when running 'script/server'? For example, I am attempting to create an HTML5 application supporting offline mode, and have an 'offline.manifest'. When I run: curl -I localhost:3000/offline.mainfest The following header ...

How should I organize complex SQL views in Rails?

I manage a research database with Ruby on Rails. The data that is entered is primarily used by scientists who prefer to have all the relevant information for a study in one single massive table for use in their statistics software of choice. I'm currently presenting it as CSV, as it's very straightforward to do and compatible with the ...

How to create picture slideshows in a rails project? Flash or otherwise

In a rails project how would I create a picture slideshow? It could be generated as flash or use prototype or something else. I just want a series of images (as a sub-part of a web page, not be the whole page) to fade into each other, and to advance manually if clicked. It would be nice if I could do things like slowly zoom into the ima...

Rails 2.3.5 - f.label :attribute not being wrapped by field_error_proc

For some reason when an object's instance has errors, the f.label tags associated with error attributes isn't wrapped about the field_error_proc. Is this the default behaviour? ...

Passing direct parameters to a Controller#method when testing via RSpec

Normally to pass parameters via in RSpec we do: params[:my_key] = my_value get :my_method Where my_method deals with what it received from params. But in my controller I have a method, which takes args directly i.e.: def my_method(*args) ... end How do I call the method with those args from within the test? I've tried get :my_met...

Why does Rails take 15+ seconds to load on Ruby 1.9?

On Ruby 1.8.7 a fresh Rails 2.3.5 environment loads in 4.325 seconds, but on Ruby 1.9.1p378 it takes 15.701s - does anyone have any ideas why? This is on a 32-bit single core laptop running Ubuntu. ...

how to use ajax with json in ruby on rails

I am implemeting a facebook application in rails using facebooker plugin, therefore it is very important to use this architecture if i want to update multiple DOM in my page. if my code works in a regular rails application it would work in my facebook application. i am trying to use ajax to let the user know that the comment was sent, ...

accepts_nested_attributes

I'm trying to use a comment style model which is attached to another model but I keep getting the error: Review(#2171315060) expected, got Array(#2148226700) With params: Processing PlacesController#create (for 127.0.0.1 at 2010-04-15 18:57:02) [POST] Parameters: {"commit"=>"Submit", "action"=>"create", "destination_id"=>"3...

Can't figure out how to use db:seed for rails in netbeans

can't seem to get my seeds.rb file to run through the command "rake db:seed". I'm using netbeans and I'm a beginner to rails, so I could be doing something really simple and stupid =/. I know you're meant to put your seeds.rb file in the db directory but netbeans doesn't seem to have one or might have renamed it... any help out there? T...

"rake db:seed" no method error

when I try and run the "rake db:seed" command the rails console outputs "NoMethodError: undefined method `db' for #" not quite sure what going on. I'm using netbeans to build my rails project which is using the built-in JRuby 1.2 would that have anything to do with it? ...

rails- display certian number of characters from a textfield

I running a rails project and I am displaying a textfield that can often be too long. If there any things I can call to only display 20 words or 120 characters on the the view page ?? ...

Refer to similar associated models with a common name

I have these models: class Bill < ActiveRecord::Base has_many :calls has_many :text_messages end class Call < ActiveRecord::Base belongs_to :bill end class TextMessage < ActiveRecord::Base belongs_to :bill end Now, in my domain calls and text messages are both "the same kind of thing" -- i.e., they're both "bill items". So I...

Implementing a SOAP 1.2 server with Rails 3

SOAP? Why would you use that? I am using Ruby Enterprise Edition and Rails 3 to write my web application. The application uses Ustream's Watershed white label broadcasting services to provide live streaming for my users. Unfortunately I have hit a snag during development. Watershed allows an application to provide it's own authentic...

Rails Pretty URL with Decimals

I have a rails application that allows searches using longitude and latitude. I have added a 'pretty' route with: map.connect 'stores/near/:longitude/:latitude', :controller => 'stores', :action => 'index' This works for integer latitude and longitude values (http://localhost:3000/stores/near/-88/49) but fails for decimal values (http...

Rails model belongs to model that belongs to model but i want to use another name

Hello. This may be a stupid question but im just starting to learn Rail thats why i am asking thsi question. I have one model called "User" which handles all the users in my community. Now i want to add a guestbook to every user. So i created a model called "user_guestbook" and inserted this into the new model: belongs_to :user and t...