ruby

Interpolation not working on Rails generator

For some reason the code I have included below does not interpolate the variables into the template. It simply copies the file over verbatim. I cannot figure out why. https://gist.github.com/60484f7b57b06b6eb3e3 The Rails version is 2.3.4. Thanks in advance! ...

Ruby environment messed up, How to uninstall ruby-gems-rails from Leopard ?

Hi, my ruby environment in my mac Leopard is all messed up. And I want to uninstall the entire ruby, gem stack and install them again from scratch. How can I do it ?please point me towards a good resource on the net. thanks ...

Does Ruby 1.9 load extensions from .dll files on Windows?

I have made a C Ruby extension on windows using microsoft visual c++ 2008 express, and put the .dll I compiled into the diectory ruby loads extensions from and required it, and it said the file couldn't be found. I read somewhere that ruby 1.9 doesn't load extensions from dlls; only so's. Is this true, or did I forget to do something? ...

chef-solo example

We are learning chef-solo and need a good example for better understanding.. Have searched a lot on net but the ideas are very confusing. can anyone suggest some examples.. and also how to run them.. We have installed chef-0.8.16 gem but couldnt figure out how to work with it.. We are using windows platform..Its urgent.. ...

redirect_to custom http header

Hi, On my current project, custom http header variable need to be set while redirecting for http basic auth. Can I instruct redirect_to for custom headers ? Thanks. ...

How to copy or clone model?

I have a model Book with attributes id, name, price. I have an instance of Book: b1 = Book.new b1.name = "Blah" b1.price = 12.5 b1.save I would like to copy b1, create another instance of the Product model. I'm tryid p1=b1.clone then p1.save but it didn't work. Any idea? And my environment is: Netbeans 6.9 RC2 JRuby 1.5.0 EDITED:...

Usage Rails 3.0 beta 3 without ActiveRecord ORM

Hi everybody! Just installed Rails 3.0 beta 3 in Windows 7. And started playing with some easy examples class SignupController < ApplicationController def index @user = User.new(params[:user]) if method.post? and @user.save redirect_to :root end end end class User def initialize(p...

Using two or more databases in rails project

Hi! I am using external Users database for different projects. Now I have got School model in my project, which has_many users and users has many schools. class User < ActiveRecord::Base establish_connection "#{RAILS_ENV}_tunnel" has_many :memberships has_many :schools, :through => :memberships end class School < ActiveRecord::...

Routes error on [POST] [Ruby on Rails]

Right now I'm building a project management app in rails, here is some background info: Right now i have 2 models, one is User and the other one is Client. Clients and Users have a one-to-one relationship (client -> has_one and user -> belongs_to which means that the foreign key it's in the users table) So what I'm trying to do it's on...

how to match items belonging to a particular category in Blogspot

In my code, I have a section that extracts and lists the different categories of posts but my problem is how to get exactly the posts that fall within that category and list them only. This is an example of my code: category = Array.new docs.elements.each("*/entry/category") { |element| category << element.attributes['term']} title = ...

ruby number to human-readable string conversion

I need to have a list with id's for each list item being #one, #two etc. Is this the most efficient way or am I missing an in built ruby function here? -num_array = ["one", "two", "three", "four", "five", "six", "seven"] -navigation[:primary_level].each_with_index do |primary_item, idx| %li{ :id => "#{num_array[idx]}"} ...

How to run some code only once in view

I have a partial view called '_comment.erb', and it may be called by parent many times(e.g. in a loop). The '_comment.erb' looks like: <script> function aaa() {} </script> <%= comment.content %> <%=link_to_function 'Do', 'aaa()' %> You can see if the '_comment.erb' be called many times, that the javascript function 'aaa' will be re-d...

Canonicalizing XML in Ruby

I'm working on a SAML gateway using Ruby/Rails and I'm attempting to write some code that validates the xml digital signature of the incoming SAML response against the x509 cert of the originating service. My problem: the signature depends on a canonicalized version of the XML that is hashed and then signed and I'm having trouble findin...

Ruby mailer is coming up with an EOFError

I am getting an EOFError (End Of File Error) on this code in my controller. The block where the error appears is at the end of the line that says UserMailer.deliver_message( I am unaware as to how to fix this, I have been stuck for about 2 months and this site was suggested. Please help. def contact @title= "Contact Us" ...

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. ...

rvm and different versions of a system library

I need to run a set of tests against the same ruby version and same gemset but with different versions of a .so library. Therefor I need to have two ruby installations (for the same version 1.8.7), each one pointing to a different set of .so files. How can I do that? Gemset usage is already too late because library binding is done when...

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...

Stepping into Ruby Meta-Programming: Generating proxy methods for multiple internal methods

Hi all; I've multiply heard Ruby touted for its super spectacular meta-programming capabilities, and I was wondering if anyone could help me get started with this problem. I have a class that works as an "archive" of sorts, with internal methods that process and output data based on an input. However, the items in the archive in the cl...

Save JSON outputed from a URL to a file

Hey Guys, How would I save JSON outputed by an URL to a file? e.g from the Twitter search API (this http://search.twitter.com/search.json?q=hi) Language isn't important. Thanks! edit // How would I then append further updates to EOF? edit 2// Great answers guys really, but I accepted the one I thought was the most elegant. Thanks!...

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 ...