Here's what I'm trying to achieve: I have a Users table and each user can be any of a dozen of types: actor, dancer, director,...which is determined after signing up. Each type of user can have any number of profiles. Eg. actors can have any number of actor_profiles, dancers cand have any number of dancer_profiles,...
The problem is how...
def plural(value, string)
"#{value} #{value.abs == 1 ? string.singularize : string.pluralize}"
end
If not, what would be a short, sweet name for this method?
...
Rails has a nice function, ordinalize, which converts an integer to a friendly string representation. Namely 1 becomes 1st, 2 becomes 2nd, and so on. My question is how might one implement the inverse feature?
To be more general I'd like to handle both of the following cases:
>> s = "First"
>> s.integerize
=> 1
>> s = 1st
>> s.integeri...
My app was working fine with Rails 2.2 and Facebooker 1.0.13, but I keep getting a 406 error with Rails 2.3.
I checked the mime type, canvas/iframe setting in Facebook, and the requests work fine outside of Facebook (i.e. I get the full app as long as I'm not accessing it within the Facebook iframe). Has something changed recently in the...
I can't understand how to use variables initialized in the controller, for example, to jQuery script (autocomplete in my case). So I'm using Rails and get my authors list. How can I refernce them in jQuery script where I' d like to use jQuery autocomplete plugin like that:
[code]
$(document).ready(function() {
$("#book_author").auto...
Is there a method in Rails that converts a symbol to a constant? I want to be able to do something like
:monkey.to_constant #=> Monkey
At the moment I have to do
:monkey.to_s.camelize.constantize
which is a bit of a mouthful.
...
Hi, I've run into a problem where I run some query and the mysqld process starts using 100% CPU power, without ending. I want to pinpoint this query. The problem is that log/development.log contains only queries that have finished. Any idea?
...
I am using Rails 2.2.2 and I would like to add an id to the html form code generated by the form_tag.
<% form_tag session_path do -%>
<% end -%>
Currently produces:
<form action="/session" method="post">
</form>
Would like it to produce:
<form id="login_form" action="/session" method="post">
</form>
The api isn't really a...
I have two different rails applications running thinking_shpinx, and one seems to not be using the correct index.
I tried setting the port in the sphinx.yml but it seems to not have any effect.
...
I know I'm doing something stupid or failing to do something intelligent - I'm frequently guilty of both.
Here's an example of what's causing me pain:
I have a module saved in /lib as test_functions.rb that looks like this
module TestFunctions
def abc
puts 123
end
end
Going into ruby script/runner, I can see that the module ...
I asked this question earlier but I'm going to rephrase it. I have a worksheet that a user can create many targets, and each target has many attributes (selects that specify attribute_id's). Each target is added through jscript. The multi-model screencast from ryan bates explains how to add multiple children on the fly, but doesn't del...
I have a has_many association like this:
has_many :respostas_matriz_alternativas, :class_name => 'RespostaMatrizAlternativa',
:order => 'respostas_matriz.codigo asc',
:include => :resposta_matriz
Well the fragment that matters is the "order". Codigo is a varchar column wich will contain in most cases numeric value...
I'm working with an application built in Ruby on Rails with very poor error handling right now. If a controller method is executed via ajax, and that method results in a 500 (or 404 or any other response) the 500.html page is rendered and returned as the result to the AJAX request. Obviously the javascript doesn't know what to do with th...
I am curious if there are any common patterns for partitioning a web application by features? An example would be to sell at multiple price tiers.
What I am asking is there a common development pattern to partition features within an application
...
Hi,
In my rails application, I have a file in lib that, among other things, sets up a filter that runs on all controllers.
When running under development environment, everything runs fine. However, under production the filter goes missing. Funny thing is, by inspecting the filter_chain, I noticed other filters remain, eg. those define...
I know that there is a rename_column transformation, but it seems that rename_index does not exist.
Do I have to use remove_index and add_index instead?
...
I'm trying to model a card game in order to learn Rails. This is different than a standard deck of playing cards in that there can be multiple copies of a card in the deck. I'm running into problems while trying to initialize the deck. So far I've got a basic Card model with various attributes (such as copies_in_deck) but no associations...
Hey all,
I'm currently trying to code a custom image cropping system similar to other ones on the internet where a user can select a cropping area and then have their image cropped accordingly. The application is in Rails and we're using Paperclip with Amazon S3 to store the files. I'm having a lot of trouble though getting RMagick to ...
I have a class defined in a file my Rails project's lib dir that will implement a bunch of utility functions as class methods. I'd like to write tests against those methods using Test::Unit and have them run as part of the project's regular testing routine.
I tried sticking a file at the top level of the test dir...
require 'test_helpe...
Can the 'Back' browser functionality be invoked from a Rails 'Back' link?
...