ruby-on-rails

Ruby on Rails - Working with times

If in a database (MySQL), I have a datetime column (ex. 1899-12-30 19:00:00), how do I sum 1 day to it? Following http://corelib.rubyonrails.org/classes/Time.html#M000240 If I want to add 1 day, it actually adds 60*60*24 days (86,400 days) r=Record.find(:first) =>Sat, 30 Dec 1899 19:00:00 -0600 r.date + (60*60*24) =>Fri, 20 Jul 2136 1...

Rails object inheritence with belongs_to

I have a simple has_many/belongs_to relationship between Report and Chart. The issue I'm having is that my Chart model is a parent that has children. So in my Report model I have class Report < ActiveRecord::Base has_many :charts end And my Chart model is a parent, where Pie, Line, Bar all inherit from Chart. I'm not sure where the...

Rails has-and-belongs-to-many form question

Sorry for the semi-generic title, but I'm still pretty new at rails and couldn't think of a succinct way to put the question. I have a basic habtm model setup: a Project has many Resources and a Resource can have many Projects. I have the database and models setup properly, and can do everything I need to via the console, but I'm having...

Help with create action in a different show page

Hi, I'm a Rails newbie and want to do something but keep messing something up. I'd love some help. I have a simple app that has three tables. Users, Robots, and Recipients. Robots belong_to users and Recipients belong_to robots. On the robot show page, I want to be able to create recipients for that robot right within the robot show...

Find tag by id using acts_as_taggable_on

I'm using Ruby on rails 2.3.8 and acts_as_taggable_on plugin. This plugin generates three tables: tags(which has the id and name of each tag) and taggings(relates tag_ids which the items that are tagged). Now, I'd like to get all the items tagged with a certain tag_id. So, I go to my Announcement model(the announcements are the tagged i...

Writing a simple incrementing counter in rails

For every Card, I would like to attach a special number to them that increments by one. I assume I can do this all in the controller. def create @card = Card.new(params[:card]) @card.SpecNum = @card.SpecNum ++ ... end Or. I can be blatantly retarded. And maybe the best bet is to add an auto-incremement table to mysql. The problem i...

Login to a Remote Service (ruby based) from iPhone

Ok here's my problem in a nutshell I've built a web service from ruby on rails. I'm using restful_authentication to create and run the login but I'm also building an iPhone application to access my web service but I can't quite figure it out. I was wondering if anyone could help me figure out a place to begin. ...

Ruby BigDecimal sanity check (floating point newb)

Hello, Hoping to get some feedback from someone more experienced here. I haven't dealt with the dreaded floating-point calculation before... Is my understanding correct that with Ruby BigDecimal types (even with varying precision and scale lengths) should calculate accurately or should I anticipate floating point shenanigans? All my va...

How can I prevent double file uploading with Amazon S3?

I decided to use Amazon S3 for document storage for an app I am creating. One issue I run into is while I need to upload the files to S3, I need to create a document object in my app so my users can perform CRUD actions. One solution is to allow for a double upload. A user uploads a document to the server my Rails app lives on. I val...

Putting create action for one model in show page of another

I asked this question earlier and got part of the way to where I needed to be. I have a simple app that has three tables. Users, Robots, and Recipients. Robots belong_to users and Recipients belong_to robots. On the robot show page, I want to be able to create recipients for that robot right within the robot show page. I have the fo...

Rails Action Mailer TLS Certificate Issues

I am trying to use rackspace ssl smtp for my mail settings for our rails application and I am receiving this error hostname was not match with the server certificate I need to find a way to disable verify on the certs for ActionMailer. Anyone know how to do this? ...

Rails check box in form decides on create action in controller?

Hi Everyone? I am trying to add a select box to the base of my create form that decides if an action runs from the controller...if that makes any sense? Basically the application creates a project in FreeagentCentral whenever a new project is made: def create @company = Company.find(params[:kase][:company_id]) @kase = @company...

Passing single attributes to associated factories

I'm looking for a way to pass fields into the factories of associated models without having to explicitly call the factory itself. For example, lets say I have some factories like so: Factory.define :person do |person| person.name "Default Bob" person.sex "M" person.house {|p| p.association(:house)} end Factory.define :house ...

what in/out bound mail system to use ? hosted or not ?

hi all I have a ruby / rails application that integrates in and outgoing email directly into the app. The app is going to be running on multiple domains each with posible many users sending and recieving email. I have looked into sendgrid, mailchimp and mad mimi as hosted services and also looked to create my own email server. There ...

Database layout for an application with geocoding features using geokit

I'm developing a real estate web catalogue and want to geocode every ad using geokit gem. My question is what would be the best database layout from the performance point if i want to make search by country, city of the selected country, administrative area or nearest metro station of the selected city. Available countries, cities, admin...

changing the db used with cucumber to the _test db instead of _development

For whatever reason, my cucumber is using my _development db instead of my _test db. How do I change that? This is what my database.yml says test: &test adapter: mysql encoding: utf8 database: myapp_test but i get the error database configuration does not specify adapter This is also at the bottom.... I can only assume that t...

Instantiating File from a remote url in a rails controller

Hi there, Is there a way to have something like this: File.new('http://hostname/myfile.zip') inside a controller? Thanks in advance ...

geokit acts as mappable through polymorphic

I have two models Store (with lat, lng columns) and Coupon. Store has many coupons, as => couponables Coupon belongs to couponable, :polymorphic => true (it's necessary for coupons association to be polymorphic for other use cases). Is it possible to do geo queries for coupons around a zipcode through the Store model by declaring the ...

Dynamically generating method names in rails

I need to generate links in my views using the url helpers such as user_path(@user), the catch is, in some cases I don't know what model I am creating this link for i.e. whether it is a user or a store or someting else I would like to be able to determine this on the fly and call the appropriate view helper, currently I am doing the fol...

How to know my username and password in mysql console

i've installed mySQL .. i entered my password , but i can't remember they've asked me for a username .. is it admin or root ? i wanna add the username and password to RubyonRails database.yml i remember i found a command that tells me the username and password in the mysql console .. but can't find it again ! that's the part i wanna ...