ruby-on-rails

Multiple remote_form_for on the same page causes duplicate ids

I've got a rails app that displays a list of items called modules. I'm iterating over these, rendering a partial for each one that includes a remote_form_for call. This all works, but fails HTML validation because my form text fields all have the same id. Is there a :prefix option on the form (or something else) I can use to get ar...

Rails: Is it not possible/necessary to html_escape all email text (in the view)?

Hi there, can anyone tell me if it is normal and OK for Rails to turn a normal quotation mark (") into & q u o t ; (and not keep the normal quotation mark) when it is html_escape-d in an email view? I.e.: h(whatever_text_that_contains_normal_quotation_marks) in an email view "signup_mail.erb". Because that would mean that email conte...

Model's method not being recognized when called

I'm using ruby on rails 2.3.2 and also using the acts_as_taggable_on puglin. That generated me two db tables: tags and taggings. As I didn't need anything more from those, I didn't create a Tag model, for example. Now the project is more mature, I need to create some methods for tags, so I created a Tag model with some methods in it. T...

Rails Functional test assert_select javascript respond_to

Hello, I am currently trying to write functional tests for a charging form which gets loaded on to the page via AJAX(jQuery). It loads the form from the charge_form action which returns the consult_form.js.erb view. This all works, but I am having trouble with my testing. In the functional I can go to the action but I cannot use asse...

Ruby on Rails: Notification System For Different Sets of Tags

I have a site with a tagging system but would like to enable users to be able to subscribe to different sets of tags of their choice so that when a new submission is made and has tags that match what the user is subscribed to they get a notification. For example, say a user is only interested in red, wallpapers that are considered large....

How do I dynamically update an instance array to hold a list of dynamic methods on instantiation?

I am trying to dynamically define methods based on xml mappings. This works really well. However I want to create an instance variable that is a array of the dynamically defined methods. My code looks something like this def xml_attr_reader(*args) xml_list = "" args.each do |arg| string_val = "def #{arg}; " + ...

Should draft records be kept in a separate table?

We're building a simple web based system whereby somebody adds a record, a CMS page for example, that gets approved by someone in charge before being shown on website. If the author then decides to edit that page later, we want to create a draft based on the live copy, on approval it will replace the old live page. We thought about doi...

MongoDB architectural question

I am using Rails and have to store 4 Models. Let's say a Post that has many and belongs to many Categories. Category on the other hand has many Qualities. At the moment I'm of the opinion, that Post and Categories are Documents. Qualities becomes an embedded Document of Categories. We're coming to the root problem: There are a lot of Vo...

Thinking Sphinx not working in test mode

I'm trying to get Thinking Sphinx to work in test mode in Rails. Basically this: ThinkingSphinx::Test.init ThinkingSphinx::Test.start freezes and never comes back. My test and devel configuration is the same for test and devel: dry_setting: &dry_setting adapter: mysql host: localhost encoding: utf8 username: rails password...

How to sort some values from an array in a controller in Rails?

I've got a links array that I'm saving to a database. The problem is that the records aren't saved in the order of the array ie links[1] is saved before links[2] and so on... This is a example from the view file: <p> <label for="links_9_label">Label</label> <input id="links_9_name" name="links[9][name]" size="30" type="text" /> <...

Fetch all entries exept those with empty column in Rails

How do I fetch all 'link' entries exept those with an 'url' column that is blank? My controller looks like this: def show @user = User.find_by_username(params[:username]) @links = @user.links.all respond_to do |format| format.html # show.html.erb format.xml { render :xml => @links } end end Thanks in...

Ruby on Rails: Modules vs. Classes

I'm trying to add a function that will be accessible throughout all parts of my program. I want something like: def GlobalFunctions.my_function(x,y) puts x + y end to be accessible for all models. Specifically I am trying to use a function like this in my seeds.rb file but I am most likely going to be reusing the code and don't ...

Old desktop programmer wants to create S+S project

I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and ...

Rails 3 memory issue

Hello! I'm developing a new site based on Ruby on Rails 3 beta. I knew this might be a bad idea considering it's just beta, but I still thought it might work. Now though I'm having HUGE problems with Rails consuming huge ammounts of memory. For my application today it consumes about 10 mb per request and it doesn't seem to release it ...

Are rails timers reliable when using Net::HTTP?

Hi All. When reading data from a potentially slow website, I want to ensure that get_response can not hang, and so added a timer to timeout after x seconds. So far, so good. I then read http://ph7spot.com/musings/system-timer which illustrates that in certain situations timer.rb doesn't work due to ruby's implementation of threads. Doe...

Rails: associate model with two of its kind

hi all, im trying to do this: class Event < ActiveRecord::Base belongs_to :previous_event has_one :event, :as => :previous_event, :foreign_key => "previous_event_id" belongs_to :next_event has_one :event, :as => :next_event, :foreign_key => "next_event_id" end because i want to enable the user to repeat events and change mult...

Tips and tricks for using emacs to develop a ruby on rails app

What are the best modes, configuration settings, or anything that makes developing a ruby on rails app in emacs better. ...

Unobtrusive jQuery and Rails with AJAX and form validation

Hello, I am looking for a way to call successfully custom function from submitHandler to do proper ajax post. Here is my custom function: jQuery.fn.submitWithAjax = function() { this.submit(function() { $.post(this.action, $(this).serialize(), null, "script"); return false; }) return this; }; Before using validate plugin I had follow...

How can I prevent Rails from "pluralizing" a column name?

I'm using dwilkie's foreigner plugin for rails. I have a table creation statement that looks like: create_table "agents_games", :force => true, :id => false do |t| t.references :agents, :column => :agent_id, :foreign_key => true, :null => false t.references :games, :column => :game_id, :foreign_key => true, :null => false e...

How can I make a url like /united-states/cities/new-york

How can I make a url like "/united-states/cities/new-york" intead of "/countries/1/cities/1" (I dont't want the word "countries" in the url) what do I have to write in route.rb to use: site.com/united-states/cities/ (to see united states' cities list) site.com/united-states/cities/new-york/ (to see new york details) and how use these...