ruby

jQuery function to load Rails partial?

I have a jQuery function that updates my data ever few seconds. But! It's not parsing the javascript it's loading. It just calls it appropriately every few seconds, and replaces my content with unparsed javascript code. setupMediaIndexPoller: function(organization) { url = '/organizations/' + organization + '/media/photos_and_video...

IDLE like interactive console for Ruby

I'm starting out with Ruby and was wondering if there's an interactive console similar to Python's IDLE, you know, with context highlighting and autocompletion. I've tried IRB, but it's fairly spartan (although it gets the work done; no question about that). Googling hasn't helped. You guys have any suggestions? ...

How do I package a rails as a standalone executable.

I've been developing a web application and a lot of customers are asking if they can host the application in their network (for security reasons). I have been looking for a way to package up a rails app into a single executable (with server and all), but haven't been able to find anything. My other requirement is that we distribute it ...

Retrieving info from hash within hash - ruby

Hey everyone, I have a quick question on retrieving information from a hash, here is the code thus far: permits_sheet.each do |row| rate_type = row[0].to_s #Converts the rate type (title) to a string row.shift #Removes the title from hash so it's not added to values row.each do |values| split_value = values.split ('=') #Refer...

Comparing two similar hashes in ruby

I'm using ruby 1.8.7 and I need to compare two hashes that I have, which are essentially the attributes of a model. Hash A is smaller than Hash B, and Hash B has all of the attributes of hash A, plus some extra attributes I don't care about. My overarching goal is to see if the elements of A are the same as the respective elements of B...

Using Rails Form Helpers with Serialized Custom Classes

Hey, I'm trying to save a hash of options in a single DB field. The form is able to save the data to the DB but not able to retrieve it again when I go to edit it (e.g. all the other fields are prepopulated except for the wp_options fields). class Profile < ActiveRecord::Base serialize :wp_options end This is my custom class: ...

How can I access "roles" in "views" in my Rails app?

In the Rails 3 app that I'm building to help me learn Ruby on (and) Rails, I'm a bit confused by the "roles/roles_users/users" tables. I have Devise and CanCan and I want to "access" these roles. Right now, I have three roles: admin staff client In the database, I have these tables (and a few others): roles (table) id => 1 || name...

ruby output question

I have the following code: File.open("/log/#{hostname}-#{@tdate}-errors.txt",'w') do |o| run=tn.cmd('String'=>'sh int', 'Match'=>/#/) { |c| puts c} run.each_line do |re| title = re.match /([\S]+)Ethernet\S+/ rep = re.match /\d+ input errors/ #o.puts run o.puts title o.puts rep end end tn.close It writes t...

IP Address Filtering

I'm looking at implementing IP Address filtering for my Rails SaaS app. In a nutshell I want administrators to be able to specify one or more IP Addresses (or a range of IP Addresses) and then my app only accept requests on their instance from the specified addresses. I'm looking at using IPAddress (http://github.com/bluemonk/ipaddress)...

xmlrpc4r keeps giving me Missing Return Value

Anyone know of a better XMLRPC testing program for ruby? ...

In Ruby on Rails, passing locals to a view, defaulting to true, won't work with ||=

if the code is do_more ||= true then when false is passed in, it becomes do_more = false || true and therefore will still be true. So this is one case where foo ||= default_value won't work? In this case it will need to be do_more = true if !defined? do_more ? ...

could not find gem 'mysql2..' when running rails script/generate scaffold command.

I got this error: Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources. Try running `bundle install`. when trying: rails script/generate scaffold post title:string I am on a mac osx, rails 1.8.7, 3.0 ...

Non-blocking IO with Ruby?

I have some questions about non-blocking IO: If I use Ruby without EventMachine on Nginx, could I leverage non-blocking IO? If i use Ruby with EventMachine but on Apache, could I leverage non-blocking IO? If the above answers are no, then it means I have to use Ruby with EventMachine on Nginx to leverage non-blocking IO? ...

RoR Passenger webserver "Extra File" errors on gem check --alien

I just installed the Phusion Passenger webserver via gem install. I then did a gem check --alien and got this error message: fastthread-1.0.7 has 3 problems .require_paths: Extra file ext/fastthread/Makefile: Extra file lib/fastthread.rb: Extra file passenger-2.2.15 has 5 problems .require_paths: Extra file ex...

Rails Nested Model Forms Error

Hi, I am trying to create a poll, which has many choices. While creating the poll, I am getting the "Poll can't be Blank" Error. Poll gets created when I removed the choices fields from the form Poll.rb class Poll < ActiveRecord::Base belongs_to :profile has_many :choices, :dependent => :destroy accepts_nested_attributes_for ...

Can't convert fixnum to string during rake db:create

Just created a new blog app using rails 3.0 my model is simple: class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end I used the commands: rails generate scaffold post title:string body:text etc. to create these files. Now I wanted to generated the db using: rake db:cre...

Aptana vs Netbeans for Ruby Development

Which IDE is more superior for Ruby development? Aptana or Netbeans? Also, is there any IDE to date that is better than the two? ...

Ruby on Rails + EventMachine?

I've heard that you have to use non-blocking code throughout the application to be able to harness true power of EventMachine. Does this mean I can't run Ruby on Rails with EventMachine? ...

Parsing text using Ruby

I have the following text which will always follow the same format: 1 "13" "241" "Rabun" "06" "County" 2 "13" "281" "Towns" "06" "County" I would like to assign each section to a hash like: locality= {:id => "", :fips1 => "", :fips2 => "", :county => "", :stateid => "", :type => ""} How would I go about doing this in R...

Why does Ruby need to force an Array into string by using "to_a" if it is clear it is a String addition?

For example: ruby-1.9.2-p0 > a = ['hello', 'world'] => ["hello", "world"] ruby-1.9.2-p0 > "foo" + a TypeError: can't convert Array into String from (irb):3:in `+' from (irb):3 from /Users/peter/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>' ruby-1.9.2-p0 > "foo" + a.to_s => "foo[\"hello\", \"world\"]" ruby-1.9.2-p0 ...