I'm trying to create a page where users can select cast their vote for certain items in the order they choose.
There are a dynamic amount of options to choose from, e.g. there might be three options to choose from [apples, bananas, oranges], and therefore each option has a select against it, with each select then having three order of p...
Hi,
I'm fetching some weather data from an online xml doc using Nokogiri, and I would like to set up a timeout for graceful recovery in case the source can't be reached...
My google searches show several possible methods for open-uri and Net::HTTP, but none specific to Nokogiri. My attempts to use those methods are failing (not too sur...
I want to construct a url within my rails app that points to another server that isn't running rails. Using url_for almost satisfies my requirements, but it requires a controller key which I don't need (redirecting to a top level page on the external site).
The reason I want to do this is so that I have a cleanly construct a url with a...
I had been using a Subversion for my source control, combined with git ONLY to deploy (push) to heroku. My pattern was: Update local working copy from latest master at remote subversion repository. Then do git commit and git push heroku (Git was set to ignore .svn stuff). This working copy I only used to push to heroku, I had another sub...
What's the best way in Ruby (with Rails, if relevant) to capitalize the first letter of a string?
Note that String#capitalize is not what I want since, in addition to capitalizing the first letter of the string, this function makes all other characters lowercase (which I don't want -- I'd like to leave them untouched):
>> "a A".capital...
Basically it will be used for categories of some articles. So the hierarchy probably only has about 5 levels max. and the hierarchy structure won't be changed frequently. Also it would be good if the plugin itself is easy to extend because I might need make categories associated with users.
I am aware that there are some act_as_tree-li...
My controller is able to create a child book_loan. I am trying to test this behavior in a functional test but am having a hard time using the assert_difference method. I've tried a number of ways of passing the count of book_loans to assert_difference with no luck.
test "should create loan" do
@request.env['HTTP_REFERER'] = 'http:...
I just started using AutoTest. As far as i can tell i have everything configured, but everytime i run autotest then i get the following error coming from my test_helper.rb:
richards-macbook-pro: $ autotest
loading autotest/rails
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I.:lib:test -rubygems -e "%w[test/unit...
What s the best design pattern or best practice for data access (database access or file system access) in Distributed J2EE, .Net Environment, rails or php ?
...
The uniqueness validator of ActiveRecord has an options to skip validation if the value is nil or blank. Even if I set both parameters to true (the default behaviour) I can create one record with nil and blank before the validation hits. I use the default SQlite3 Database sqlite3-ruby (1.2.5).
Edit for clarification: I get the expected ...
Hi,
I have a Ruby on Rails application I'm using Ruby 1.9 and Rails 2.3.4 and I want users to upload videos so I installed Paperclip gem but I'm getting this error from Rack. The fact that it says it's "invalid byte sequence" makes me suspect that it's from Ruby 1.9.
any ideas?
Thanks,
Tam
Rendering posts/new
Rendered posts/_form (...
I'm a one-man-band at the company I work for. I develop a Rails application for internal use within the company. Since the beginning of the project I have used SVN for source control and done most, but not all, development in trunk. Occasionally, when I have had very significant changes to make, I have branched and made the changes mergi...
Hey guys. I'm creating a rails app and being one of the first times I've used the MVC pattern, let alone rails, I'm running into ambiguity and uncertainty. I already defined an application.html.erb which is working great, it has a yield statement which renders the current action's view.
I want application.html.erb to contain some dynami...
I have the Shovell source code from the book Simply Rails 2, but I'm having problems running it.
"Getting started
Here’s how to get rolling:
1.
Create your databases and edit config/database.yml
Rails needs to know your login and password.
2.
Use script/generate to create your models and controllers
To s...
I a little confused about how this work even if it works properly. I have a model that has two association to the same other model.
Company has an owner and company has many employees of the class users.
here is my company model:
class Company < ActiveRecord::Base
validates_presence_of :name
has_many :employee, :class_name => '...
"output" is a serialized OpenStruct.
def title
try(:output).try(:data).try(:title)
end
What would be better? :)
...
I have the gem working nicely for gmail on my mac. I switch to production and the stuff stops working.
Also, Blackbook doesn't work at all with gmail accounts. Any suggestions for a solid way too import contacts in Ruby on Rails?
** pls note that Ubuntu is running 1.8.6 vs 1.8.7 on my Mac. I wonder if that is causing different bahavior...
I have the following models:
class Person < ActiveRecord::Base
has_many :images
has_one :preference
end
class Image < ActiveRecord::Base
belongs_to :person
end
class Preference < ActiveRecord::Base
belongs_to :person
end
I am trying to fetch all images that are public and at the same time eager load the people who own those imag...
I have this data structure:
Root
Child
Child
Child
Child
Child
Child
My models are set up like this:
Root: has_many :children
Child: has_many :children, belongs_to :root
For some tasks every child has a back reference to the Root record.
How can I make sure, every time a new a child gets inserted, the root re...
When doing a search in active record I'm looking for record's that do not have an archived bit set to true.
Some of the archived bits are null (which are not archived) others have archived set to false.
Obviously,
Project.all(:conditions => {:archived => false})
misses the projects with the archived bits with null v...