ruby-on-rails

Creating interactive ajax javascript widgets in ruby / rails

Looking to create interactive javascript widget using ruby-on-rails that can be placed on any website. I am able to create a basic widget. Its fairly straightforward (eg. using document.write) This works fine for taking data from my server and putting it into the widget but its very static. But how do I create something more dynamic ...

rails relationship using unique key

Hi, I have 2 entities: Table/Entity 1: RetrievedDataRecords Columns: id record_key Table/Entity 2: SourceKeys Columns: id key_name (unique key) I cant alter these tables for legacy reasons, but want rails relationship between RetrievedDataRecord and SourceKey using record_key and key_name (they are the same key) in RetrievedDat...

Overwriting data to the model

I am using reading a table from Oracle and writing the data to a model using cronjob everymidnight so that it help me caching the data and enhance speed. BUT I am using create method to writing the data in model which create new entries and I get duplicate data in my model everytime. Is there any method in model to update the data or ove...

Embedding images in a Rails Builder generated RSS feed

Hi, I'm currently building an RSS feed for my Rails application using Builder (the wealth of tutorials out there for doing it this way helped), but become a little bit stuck when it comes to adding an image alongside it (which has been uploaded via Paperclip), like a lot of the top publications do. I'm currently using this to make the t...

Is attr_accessible inherited by derived classes whe using STI?

I've got a class structure similar to this for a family of classes using STI class Root < ActiveRecord::Base attr_accessible :root_prop end class Child < Root attr_accessible :child_prop end class Grandchild < Child attr_accessible :gc_prop end All my properties were working fine until I added the attr_accesible markers, so I...

How to edit docx with nokogiri and rubyzip

I'm using a combination of rubyzip and nokogiri to edit a .docx file. I'm using rubyzip to unzip the .docx file and then using nokogiri to parse and change the body of the word/document.xml file but ever time I close rubyzip at the end it corrupts the file and I can't open it or repair it. I unzip the .docx file on desktop and check th...

Accessing controller in Cucumber to test sign-in

First off - I know that this is generally horrible practice, because Cucumber is meant to only test outputs. I just want to do this for one veryveryvery specific case. I have an app that handles user authentication using a cookie set by another app I maintain. I'd like to write a very simple integration test for authentication: Given I...

Ruby on Rails CSV putting &quot;&quot; instead of actual quotes

I am attempting to generate a CSV file. Everything is fine except for blank fields, I'm not quite sure have &quot;&quot; instead of actual quotes. I've provided the code I'm using to generate the file and some output. <% headers = ["Username", "Name", "E-mail", "Phone Number"] %> <%= CSV.generate_line headers %> <% @users_before_pagina...

How to make sure that capistrano recipe is loaded in rails3

I have a rails2 plugin which has a capistrano task. That file resides at ~/myplugin/recipes/ . I am converting this plugin into a gem which should work with rails3. This is what I did. I created recipes file inside the lib/myplugin directory. So my file looks like ~/dev/myplugin/lib/myplugin/recipe.rb And added following line to my ...

"Wrong number of arguments (1 for 0)" in the "create" action

I've got a functional test that errors on the following method, saying that the first "Quality.create!(..." statement has too many arguments, which doesn't make any sense to me at all. Running Ruby 1.8, Rails 2.3.5 def reset_quality_lut Quality.delete_all Quality.create!(:value => 1, :name => "Scrap", :extended_na...

Undefined method has_attached_file after Paperclip installation?

Not sure if I've done everything right here. I added the Paperclip gem to my Gemfile and did bundle install. I followed along with the readme instructions on Paperclips Github page. I wasn't sure if I needed to install ImageMagick. But, I found a script on Github for installation on Snow Leopard, so I ran: rails plugin install http:/...

has_many through issues when adding attributes to the join table

I have models moves, neighborhoods and communities. Neighborhood.rb has_many :communities has_many :moves, :through => :communities accepts_nested_attributes_for :communities Move.rb has_many :communities has_many :neighborhoods, :through => :communities accepts_nested_attributes_for :communities Community.rb belongs...

How do I make my div IDs variable in rails?

I feel like there should be a simple way to do this, but I just don't know what it is. I have a list of data to display, and I want to include an AJAX "Read More" function to expand information at the bottom of each segment. To do this, I need unique div IDs within each segment. I have this code: <% for choice in @student_choices %> ...

Managing User Accounts with Rails 3 and Devise

I have implemented Devise in a Rails 3 application and I need admin users to be able to manage users. Users are not registerable and therefore an admin must create accounts. What would be the best way to go about this? It doesn't seem very DRY to create my own UsersController when Devise already provides Devise::RegistrationController b...

Subscribe to newsletter form rails 3

Hi, I'm new to rails and I would like to know how to make a form that submits to a database. I have tried devise but it seems that it deals with logins/users and it's not working for my purpose. I don't want anyone to do it for me, I have to learn :). ...

Getting a "has no column named" When Loading Rails Fixtures

EDIT: This is with Rails 2.3.5 For some reason, when I try to associate a CreditCard with Band in my project, I get the following errors SQLite3::SQLException: table credit_cards has no column named band: INSERT INTO "credit_cards" ("created_at", "vault_token", "billing_zipcode", "billing_first_name", "updated_at", "band", "billing_sta...

passing hash object values as search parameter

I have a table "Email" with field "contents" where the data are stored as hash object. I want to do search in this table with parameter "email => [email protected]" where :email is key and "[email protected]" is value of a hash object. Thanks in advance ...

How to create Rails app with Facebook single sign-on ?

I am creating a rails application where I need to allow users to login to my site with their facebook IDs. How do I do that. I don't understand the facebook documentation much. Are there any other clear resources on the internet? thanks ...

How to conver JSON collection into Hash using Rails 3

Hey, I am having JSON collection fetched from MongoDB & I want to convert it into Hash. How can I do so..? Thanks in advance.. ...

IP address in rails

Hello, I have Rails 2.3.8, Ruby 1.8.7, Mongrel Web Server and MySQL database. I need to find the IP address but I am facing problems. I am in the development mode. I googled and found code, that its simple to get the IP address using request.remote_ip but, I am getting the output only as 127.0.0.1 In the controller, I have def ind...