ruby-on-rails

Do Ruby on Rails sites have performance issues?

Are Ruby on Rails site usually slower than java or .net sites? (This is assuming developers are not abusing the technology.) A lot of Ruby sites I have seen have performance issues. ...

How to get the label builder not to force downcase everything?

Hi, when I'm using the label helper in a form contex, the label is getting downcased. Can I change this behavior? example: <%= f.label "Things Are Getting Big" %> produce: "Things are getting big" but I want "Things Are Getting Big" using rails 2.3 ...

Rails output number of records with X in field?

Hi Everyone, I have a number of records in a model called Kases, each kase record has a status which can be Active, On Hold, Invoice Sent or Archived. I am trying to work out how to add a number on the dashboard for the total number of kase records, the total number of kase records marked as on hold, the total number of kase records m...

Sanitizing RSS input in Rails

Hello, I'm pulling in the RSS feed from Craigslist into a rails app I'm building. When I try and insert content from the posts into my database, there's plenty of bad characters that cause the database to choke. I've tried a few different methods (the Sanitize plugin, hpricot, regexing the input) but nothing seems to work right. I'm ...

Best way to handle 404 in Rails3 controllers with a DataMapper get

It's very simple, I want to handle a normal [show] request with a call to DataMapper like I did in Merb. With ActiveRecord I could have done this: class PostsController def show @post = Post.get(params[:id]) @comments = @post.comments unless @post.nil? end end and it handles the 404 by catching the resource's exceptions. ...

RVM, Ruby 1.9.2, Rails 2.3.8, Passenger and "invalid byte sequence in US-ASCII"

I just started the upgrade process from Ruby 1.8.7 to Ruby 1.9.2 (using RVM). I have all my applications running using 'script/server' (or 'rails server') with 1.9.2, however, only Rails 3.0.0 RC applications work with Passenger. The error message given by Rails 2.3.8 applications is: invalid byte sequence in US-ASCII I'm guessing ...

Rails 3 content_for issues

Hi, I've recently built a fairly deep nested form using http:// github.com/timriley/complex-form-examples for guidance. The form partial uses the following in order to render new fields when a link is clicked: <%= yield :warehouses_fields_template %> <%= yield :ratgrades_fields_template %> The content for these is generated i...

Rails3: Unit testing a library doesn't load the fixtures

I added a unit test manually to test a library I'm building. I have some fixtures which are tested in their corresponding models without any issues. The test case inherits from ActiveSupport::TestCase which runs fixtures :all. require 'test_helper' require 'mylib' class MyLibTest < ActiveSupport::TestCase @user = User.find(1) te...

accepts_nested_attributes_for as Rails 2.1.0 plugin (or equivalent)

I've developed a Rails app under Rails 2.3.5, and have made use of accepts_nested_attributes_for. Now I come to deploy it, I find my deployment environment is Rails 2.1.0 with no scope for upgrade. Obviously, 2.1.0 doesn't have accepts_nested_attributes_for. Is there any way I can get the nested functionality under 2.1.0, as a plugin, s...

user subscription and authenticity_token need CAPTCHA ?

I am currently developing a user subscription module and I would like to know if I need to use captcha in rails 3 because authenticity_token sound good. Thanks ...

Rails, custom finders.

So I want to be able to get an object using find_by_id_or_name, I feel like I saw another question like this but am trouble finding any resources on making my own finder. ...

Passing a javascript variable to Ruby in a combo box nav

Updated Example I am using a Select Box as a nav. When I select an item, I would like to be redirected to that page. = select (@organization, "tabs", @organization.tabs.collect { |t| t.title }, {} { :onchange => "escape_javascript(#{ render edit_organization_tab_path(@organization, this.value)})"} ) So this example does not work beca...

Rails: Multiple models in one form problem in AJAX

I'm having a problem with a rails form that contains a dynamic number of new models in one form. The models are all from the same class and are nested under one single model. How I have it set up right now works great for HTML form submissions. But, when I change the form from form_for to form_remote_for, the parameters get completely me...

How do I handle large amounts of logfile data for display in dynamic charts?

I have a lot of logfile data that I want to display dynamic graphs from, for basically arbitrary time periods, optionally filtered or aggregated by different columns (that I could pregenerate). I'm wondering about the best way to store the data in a database and access it for displaying charts, when: the time resolution should be varia...

How can I test common Rails controller behavior while staying DRY?

I've been writing RSpec tests for some Rails controllers and I've discovered a strong impulse to ensure that the Authlogic authentication is working properly. I also feel like I should be verifying that each action uses the same application-wide layout. However, writing tests for this behavior in every single action seems silly. What I'...

Rails i18n and yml structure for form labels

According to the ActionView documentation. Quote: The text of label will default to the attribute name unless a translation is found in the current I18n locale (through views.labels.<modelname>.<attribute>) or you specify it explicitly. I have a "user" model and a registration form. Here's a snippet of the relevant part: <% form_f...

Database SQL Compatibility

I am deploying a Ruby on Rails application that I developed with Sqlite3 to a server with either MySQL or PostgreSQL. I quickly discovered that the "group by" and "strftime" functions that I am using heavily to produce by-month rollup reports are working differently or not compatible between the various databases. I can refactor my co...

Rails, get column name of value

This might be a little odd, but how can I get the column name from object in my model? For example, I have a table which happens to have all 50 states in it as separate columns (I know, I know that could be way more efficient), so they look like: al_allowed, ak_allowed, etc... These columns are booleans, but I wanted to know in my mo...

Character indices of a string containing unicode characters

I'm linkifying @mentions in status messages returned by Twitter's API. One of the tweets has a unicode character in it. Parsing the JSON (with either the json gem's JSON.parse or ActiveSupport::JSON.decode) returns a string that displays correctly, but the indices for the start and end of the @mention specified by the entity don't ma...

cap deploy:cold fails with 'No such file or directory - git rev-parse master' error

Hi, I am trying to deploy my rails application for the first time. Server is running Ubuntu 10.4 server (64bit) Local machine is running Windows XP. Repository is at github I have successfully run cap deploy:setup but when I run cap deploy:cold I get the following error: D:\Rails\rails_apps\fx>cap deploy:cold You are running ...