Hi all,
I have 2 polymorphic associations through which I need to query.
I have a news_article table which has a polymorphic association to teams, players, etc. Those teams, players, etc have a polymorphic association to photos through phototenic.
I need to find all articles that have at least one picture that is 500px wide.
The Ar...
While writing functional tests for a controller, I came across a scenario where I have a before_filter requesting some information from the database that one of my tests requires. I'm using Factory_girl to generate test data but I want to avoid hitting the database when its not explicitly needed. I'd also like to avoid testing my before_...
I remember coming across this when first watching some Ruby videos, but I can't find it again. When Ruby shows something like this:
#<Role:0x11157b630>
,what is going on?
I have three roles (admin/staff/client) and I would like to show one of these, not
#<Role:0x11157b630>.
Any idea how I could do that?
Cheers!
...
My one column name is "usage" and it's conflicting with mysql keywords.
To solve out that issue i was passing usage like `usage` with ActiveRecord. That solved my problem.
CsvHeader.find(:all,:conditions => ["`usage` = ?",usage]))
Right now i am attaching db2 as my database.
db2 is not accepting &&. so i have replaced && with and.
Ano...
I have a user model on my app, and my password field uses sha1. What i want is to, when i get the sha1 from the DB, to make it a string again. How do i do that?
...
I have an application running an old version of Rails (2.2.2) and Passenger that I got up and running using Ruby Enterprise Edition 1.8.7. However, I soon found there were some incompatibilities between older versions of Rails and Ruby 1.8.7, and decided to downgrade to REE 1.8.6. However, now the application fails to start with a LoadEr...
My validations were working for a while, or so I thought. Now I come back to them after a while doing something else and I am getting the error above. I think it means I am creating a nil object with the .new method but I am just lost. It seemed to be a problem with the creation of a new object by the controller because even if I # ou...
I have a model called Contact with an attribute called phone_number. I have some custom setter methods such as
def prefix=(num)
self.phone_number[3..5] = num
end
When I call @contact.update_attributes({:prefix => '510'}), I don't get any errors and @contact gets changed, but the changes don't make their way to the database. I've tr...
I have a rubygem that defines a custom SemanticFormBuilder class which adds a new Formtastic input type. The code works as expected, but I cannot figure out how to add tests for it. I was thinking I could do something like load up Formtastic, call semantic_form_for, and then ad ann input that uses my custom :as type, but I have no idea w...
I'm developing a rails application using the facebook api. I've seen a few different ruby gems for integrating with facebook, but the look dated. Is it best to write low-level calls myself? Or is there a decent and current gem available?
...
I think the problem is trivial.I have two models: User and Betting.
User
has_many :bettings
Betting
belongs_to :user
I just want to get the users ordered by who made more bettings.
Sorry, for my english
Thanks in advance
Francesco
...
I am going through a video tutorial that was using Rails 2.3, and they did:
<%= first_array = ['a', 'b', 'c'] %>
When they did that, the output they got was:
abc
When I am trying to follow along, on my setup (Rails 3.0), I get:
["a", "b", "c"]
Is this difference normal or did I do something incorrectly?
Thanks.
...
I know it's possible to sit between a payer and payee using PayPal by just storing payee's PayPal account information.
Is it possible to take a percentage of the that transaction and pay it to a different PayPal account. Basically acting as a service fee for using our website?
If it helps, I would probably be using Active Merchant f...
Basically, I would like to write a rails 3 app that
is embeddable in other rails 3 apps (basically some routes, a controller, and some views, no persisting models)
works standalone
can be bundled up into a gem and be launched from a command (this one is more a nice to have)
From what I have read, rails engines would totally solve my ...
I gathered from the much famed scaling rails screencasts that at some point when your site gets big and bigger, proxy caching is the way to go. Proxy caching uses etag, among other things and since etags can be more specific and strong validator is perhaps the way to go. However, I also hear that in server farm scenarios the etag is not...
I've started using the metasearch gem http://metautonomo.us/projects/metasearch/ for a ruby on rails 3 app after seeing it recommended in another stackoverflow post.
I would like to have a single text field on a search form that can search in multiple fields rather than have one text field for each. I just havn't been able to figure it ...
Is there a way to get "rails console" to load .irbrc? Or am I supposed to use something else?
...
Currently I use nginx + passenger for serving my rails app. I have been doing some research on reverse proxies and a few names pop up (squid, varnish and nginx mostly).
1 - Now If I am using nginx as my web server can I stil use it as my reverse proxy?
2 - The general sense is that most sites use nginx for proxying static content and a...
If I have a collection of objects through a 'has and belongs to many' association in Rails (e.g. the album 'summer photos' has a collection of photos), how can I arbitrarily change the order of the elements in that collection? For example, there is a default index that would yield @album.images[0] or .first. how would I go about ch...
I am a relative beginner at Rails 3 routing and it has now caused me enough pain that I want to figure out the real solution.
A couple of details:
I have some semi-restful controllers that contain some methods outside the standard seven new, create, edit, update, destroy, etc.
Generally, I want my routes page to map everything to 'con...