#Vote Model
belongs_to :voteable, :polymorphic => true
belongs_to :voter, :polymorphic => true
#votes table
Voteid: integer, vote: boolean, voteable_id: integer, voteable_type: string, voter_id: integer, voter_type: string, created_at: datetime, updated_at: datetime
#User
has_many :voteables, :foreign_key => :voter_id, :class_name =...
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
...
Hey everyone,
I have a simple problem for that I'd like to hear your thoughts:
I have this URL in Rails http://example.com/hosts/show/somehost
I'm getting the 'somehost' part via params[:id]. I'm calling URI.encode on 'somehost' but this does not encode '.' characters. Rails won't recognize ID parts with points in it so I tried to rep...
Hi, I have a rails app which I want to make searchable with tenderlove's texticle. In the console it works fine, but in my app I get an error like this:
/opt/local/lib/ruby/gems/1.8/gems/texticle-1.0.3/lib/texticle.rb:65:in `index'
/Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:92:in `call'
/Users/v...
I wonder how TDD is done in Rails.
Here are the steps I have written down:
Create migrations and models for the database tables
Add associations to the models
Write unit tests for the models and run and see them fail
Add validations to the models
Run tests and see them pass, if not, edit the code till they pass
Create routing, control...
How do I render a view within another view... in rails... is it possible?
...
Hi,
I have a Rails application for which I use devise to authenticate my users and this works great. I now want to write an iPhone application (not just a WebUI but a proper APP) that accesses the same data and so requires the same authentication. How should I go about doing this?
I want to login using devise and keep the session ope...
Im a beginner when it comes to TDD and BDD.
This is what I know:
To use TDD in Rails I use it's built-in unit-, functional and integration tests.
To use BDD in Rails I use Cucumber.
So are these two different techniques that shouldn't be used together?
If I use TDD, then I shouldn't use BBD/Cucumber and vice versa?
Please enlighten...
Hi I have has_and_belongs_to_many relationship between Posts and Comments and in my edit action I have form that returns me list of ids 1,3,5,8 etc. I want build relationship between my current model and all models which ids are in the list so @post.comments will return Comments with 1,3,5,8 ids
In fact I need execute
DELETE FROM comm...
I am inserting data from CSV to database.
While i am trying to insert this row
2 créditos,,,,R,75,,
into my database i am getting this error Mysql::Error: Incorrect string value: '\xE9ditos...' for column 'message' at row 1: .
...
When I attempt to load the Rails console (or load my website running Apache/Passenger), I get an error that it can't load a gem that I've already installed:
> script/console
Loading development environment (Rails 2.3.8)
no such file to load -- authlogic
/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/...
I've got a group of messages in mongo which I am retrieving in rails with
@messages = current_user.user_messages(@user)
I now want to select the number of messages which were created in the last week, so I thought I could take the @messages and query that directly with
@countRecent = @messages.count(:conditions => {:created_at =>{'$...
I'm new to testing strategies and mocking, and I'm having a tough time figuring out how to mock a call to an external service. I'm sure it's something easy I'm missing, I just don't know what exactly.
I'm using the Braintree gem to charge for subscription services through the Braintree gateway, and I wanted to mock the Customer create ...
Hi
Is it possible for a model to belong_to, two models and have a nested relationship?
i.e of what i want
class trainer
has_many :appointments
end
class appointment
belong_to :trainer, :customer
end
class customer
has_many :appointments
end
at the moment i have only the customer and appointment models which are nested e.g of what...
how do I use fancybox with authlogic?
I want to use fancybox for doing a login... loading the login form generated by authlogic
I found this http://net.tutsplus.com/tutorials/ruby/how-to-build-an-unobtrusive-login-system-in-rails/ but fancybox works differently.
Any help?
...
Let's say you had a web app where people could submit links, links for their own websites and links for website's that they don't own. The submission form is pretty much the same in both cases except when they submit the domain of the link.
If the user is submitting from a list of their own registered websites, they'd get a drop-down li...
I've set up Capistrano to ask me which git tag I want to deploy:
# deploy.rb
set(:branch) { Capistrano::CLI.ui.ask('Tag to deploy:') }
This works as expected - if I specify v0.75 it will deploy that tag.
However, I'd love it if I could print out the list of my tags before I get asked which one to deploy, with something like this:
gi...
Hello,
I'm trying to create a gem and I would like to have a feature inside it that takes the client ip address when using it. Basically it's just like the rails ActionController request.remote_ip, but within the gem I don't want to rely/depend on rails.
Is there any way to have something like this purely using Ruby?
I've found this, ...
hi,
I am using select_tag, and onchange i want to check if selected option value = "Add New Item"
then call function
I have used code below
<%= select_tag "name", options_for_select(searchresults.collect{ |w| [w.first_name, w.id]} + ["Add New Name"]),{ :onchange => "if $('+this.value') == "Add New Name" { addNew(); }" ,:class =>"frm...
Hi,
I've added a column to a db in rails via a migration, and updated new.html.erb to add the field to the form.
The correct data is in the request params, but the insert query that is generated has a null for the column every time.
Here are the request params:
{"commit"=>"Create",
"assignment"=>{"start_date"=>"08/04/2010",
"proj...