ruby

Uninitialised constant during DB migration on ruby rails mysql & os x

This is a strange one, I have created the following migration which fails to run. class CreateCategories < ActiveRecord::Migration def self.up create_table :categories do |t| t.column :name, :string t.timestamps end news_category = Category.create(:name => 'Site News') change_column :articles, :category_i...

ActiveRecord returns data in ASCII-8Bit Under Ruby 1.9.2-rc1.

Further to the title, when loading data from ActiveRecord the encoding is always set to ASCII-8Bit in spite of my best efforts to force the encoding. I have entered as much detail as possible here to try and build a good error report someone could use to help me out! The project is using the following technologies: Padrino Framework R...

How Ruby's authlogic is compared to Python's repoze.what/who library?

I am trying to understand architecture of authlogic and repoze.what/who libraries but I could get the first level architectural definition. repoze packages seems to use the zope modules at some level.. Are there any equivalent or easier authentication framework like authlogic available in python? (I do not use Django.. I use Pylons) A...

Query all the users in a system with LDAP

I am using ruby's net/ldap library for this problem but in reality the driver language shouldn't really matter. I need to find a way to be able to get all the users from a system and find out which users do not have emails assigned to the account. Is it possible? I can connect to and even create new records through LDAP, and can return...

Polymorphic abstraction of Models and potential MI in rails?

We have Models like Supplier, Distributor, Vendor, Buyer in our schema. These entities have some common attributes ( like name, description, sales offices etc.) but mostly they have a divergent schema with different has_many :through associations ( a vendor has many stock_keeping_units , others do not) because of which they needed to be ...

How to add an attribute to mechanize's(ruby) Field class and have it use my extended class.

Basically, when I store a form object I want to some extra analysis on the fields and set a new attribute based on that analysis. Should I just go inside the code and add the attribute manually, or is can I just extend it? How do I get mechanize to use my new class when it gets these fields? Thanks! ...

Languages / stacks for deployment

I'm working on a rather intensive rewrite and given a choice of the following options: JSP / Java running on Tomcat PHP running under Apache Ruby (running under I'm not sure, ROR?) A couple of basic questions I would like to know about the above. Speed is a concern. We have a MongoDB backed database, so we shouldn't need to be waiti...

Merging structs with same user id and then sorting based on attributes...

I have any array of structs. Each struct in the array has the following attributes: user_id num_hot_dogs_eaten date_last_pigged_out Here's what I want to do: Find the structs with matching user_id's, and merge them into one struct record where num_hot_dogs_eaten is the sum of all matching records and date_last_pigged_out is the m...

Requiring gem in Rails 3 Controller failing with "Constant Missing"

I've seen this asked a few times in other threads, but none of the answers seem to apply. Environment: Rails 3 amazon/ecs gem from jugend. The lone file is here: http://github.com/jugend/amazon-ecs/blob/master/lib/amazon/ecs.rb my gemfile has: gem 'amazon-ecs', :git => 'git://github.com/jugend/amazon-ecs.git' Everything works in ir...

Custom Subdomains in Sinatra app

I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com). I found this to extract subdomains (http://gist.github.com/55784#file_subdomains.rb) but I'm having a hard time implementing it. Any ideas? I have an Account model (datamapper) with a field called account name, whic...

Error installing Ruby 1.8.6 and openssl using RVM under Snow Leopard

Hi, I'm trying to install ruby 1.8.6 on Snow Leopard using rvm. I tried: rvm install ruby-1.8.6-p111 and got an error explaining make couldn't find openssl. make[1]: * [openssl_missing.o] Error 1 I then tried: rvm install ruby-1.8.6-p111 -C --with-openssl-dir=/System/Library/OpenSSL (Snow Leopard seems to come with openssl and this s...

Set Authlogic validate_login_field to false on user update

We have a current database of users who can have any symbol in their username. We have started using authlogic for authentication. So, any current users updating any of their information fail validations because their login has unaccepted characters. We want to prevent new users signing up from using symbols not accepted by authlogic, ...

Trying to install ruby-filemagic on Snow Leopard using brew rather than ports

Hi, I'm trying to install ruby-filemagic. I tried sudo gem install ruby-filemagic -v 0.2.2 and got: ERROR: Error installing ruby-filemagic: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for magic_open() in -lmagic... no *** extconf.rb failed *** C...

How can I get rid of this ruby warning?

I have just installed ruby 1.9.1-p429 with macports. Every time I use it, it displays this error message: $ ruby1.9 -e "puts 'hi.'" Error loading gem paths on load path in gem_prelude can't modify frozen string <internal:gem_prelude>:69:in `force_encoding' <internal:gem_prelude>:69:in `set_home' <internal:gem_prelude>:38:in `dir' <inter...

Limit each do loop

If I have the following, <% @feed.sort_by{|t| - t.created_at.to_i}.each do |feed| %> <% end %> How can limit it to only show the 10 most recent results ...

rails 2.3.5 with ruby 1.9.1p429 : incompatible character encodings: ASCII-8BIT and UTF-8

Hi, I tried the ruby hacks for utf8 (from : http://gist.github.com/273741) ... and I'm still getting the following error: ActionView::TemplateError (incompatible character encodings: ASCII-8BIT and UTF-8) What is bizarre for me is that the same content if retrieved with a post action (searching the app with an html from) it is display...

CSS 2 Sass: How do I change the output format of the generated SCSS?

I want to convert CSS to SCSS that looks like this: .top { margin-top: 1em; margin-bottom: 1em; nav { background: #333; } ul { padding: 0; display: table-row; } li { display: table-cell; } } Instead, I am getting this: .top { margin-top: 1em; margin-bottom: 1em; nav { background: #333; } ul...

How to make 'Shoulda' test output easier to read and in Colour!

I currently working on a project which uses Spree Cart and which has hence forced me to switch from testing with RSpec to testing with Shoulda. I really like the output I get from rspec and am wanting to get similarly readable output using Shoulda. Specifically how do I achieve similar output as I would achieve with the rspec command ...

ruby - why TrueClass and FalseClass instead of Boolean?

I was working on serializing values when found out about this one. Ruby has a TrueClass class, and a FalseClass class, but it has no Boolean class. I'd like to know why is this. I see some advantages in using a Boolean - for example, String parsing could be centralized on it. Ruby developers are smarter than me, so there must be a lot ...

How to call Ruby(.rb) file in J2ME

Hi All, I have a problem with Client-Server program. Client is J2ME and Server side Scripting is RUBY. I need a help for How to call Ruby(.rb) file in J2me (Client) program. ...