How can I migrate my data from my rails app from mySql to SQLite
How can I migrate my data from my rails app from mySql to SQLite? Is this possible? ...
How can I migrate my data from my rails app from mySql to SQLite? Is this possible? ...
I have a join table that I'm using to find available services for an order form; in that table is the utility_id and a company_id. What I want is a group (hash) where the keys are the utility names and the values are hashes of the corresponding companies. I got the following... Service.find(:all).to_set.classify { |service| Utility.fi...
This question deals with optional arguments passed to a Ruby block. I'm wondering if it's also possible to define arguments with default values, and what the syntax for that would be. At first glance, it appears that the answer is "no": def call_it &block block.call end call_it do |x = "foo"| p "Called the block with value #{x}" e...
So I have this big, hairy if/else statement. I pass a tracking number to it, and then it determines what type of tracking number it is. How can I simplify this thing? Specifically wanting to reduce the number of lines of codes. if num_length < 8 tracking_service = false else if number[1, 1] == 'Z' tracking_service = 'ups' els...
I'm aware of the possibility to mark untrusted objects as tainted, but what's the underlying purpose and why should I do it? ...
I'm hoping to avoid building this if it already exists. Does anyone know of a plugin for Ruby on Rails that will generate a screenshot of a web site? Thanks in advance to anyone who can help me find one. ...
I have a few variables: name age address phone social_security email weight And an array called personal_details with each of these values in positions 0-6. So I assign values like this: name = personal_details[0] address = personal_details[1] phone = personal_details[2] social_security = personal_details[3] email = personal_details...
What's the best way to have a setup run before every method in an entire test suite (not just one test class)? Rspec allows you to define global before and after blocks. Is there a clean comparable way to do this in Test::Unit that doesn't involve mixing a module into each test class? ...
I'm trying to follow the installation instructions for Ruby on Rails from Hivelogic.com. I've done this before on previous installs of OSX without trouble. I'm having trouble this time installing on Snow Leopard. At the end of the "make" step installing Ruby, I get a number of errors related to readline. Not sure if this matters, but h...
Hey everybody, In a little app I'm building, I'm using the the twitter_oauth gem (source of the methods I'm using), which incidentally means I'm dealing with the JSON ruby gem. I'm using the messages method, whose source is as follows: def messages(page=1) oauth_response = access_token.get("/direct_messages.json?page=#{page}")...
The story so far: I have a rails app with a model named "Term". All is well until trying to install Cucumber. Upon running rake cucumber I get Term is not a class (TypeError) This happens because Cucumber includes another gem, 'term-ansicolor' (to do the nifty colored text output in the console), and term-ansicolor defines a modul...
What's the shortest way to combine say 20 256x256 thumbnails into a single large image of 4 rows by 5 columns using RMagick? ...
I'm aware of how include? works, however not really clear using it with multidimensional array, or a hash (is this possible with a hash?) For example, given I have a hash that looks like: @user.badges => [{:id => 1, :name => 'blahh', :description => 'blah blah blah'}, {:id => 2, :name => 'blahh', :description => 'blah blah blah'}] Can...
I'm using Nokogiri::XML to parse responses from Amazon SimpleDB. The response is something like: <SelectResponse xmlns="http://sdb.amazonaws.com/doc/2007-11-07/"> <SelectResult> <Item> <Attribute><Name>Foo</Name><Value>42</Value></Attribute> <Attribute><Name>Bar</Name><Value>XYZ</Value></Attribute> </Item> </S...
Id like to be able to create client keys for an openvpn setup from within a ruby script. Im wondering how to go about this. Im assuming i coudl create my own CA and key generation code in ruby. Or i could somehow just call the easy-rsa scripts (non-ruby) from within my ruby script and somehow simulate the keyboard when easy-rsa prompts...
I've installed super_exception_notifier by running: sudo gem install super_exception_notifier and then I've tried enabling it in my project (which already has mailing working, since it sends emails for other purposes) like this. On environment.rb I added # Notification configuration require 'exception_notifier' ExceptionNotifier.conf...
I have a bit of code that basically displays the last x (variable, but let's say x is 20 here) updates made in a given table. In one of the unit tests for it, I have this snippet: EditedItem.push_to_queue(hiddennow) #create some new entries and save them 20.times{ EditedItem.push_to_queue(random_item) } Queue.get_entries.each{|entry| a...
So I semi-asked this in another thread about how to get .max and return a value to a screen. All where very good answers, I just didn't ask the entire question. I ended up going with: hash_example = {777 =>["dog","brown",3], 123=>["cat","orange",2]} #hash example h =hash_example.values.collect{|a|a[0]}.max #change .max value based o...
Oddly enough, most of this works as it has been written, however I'm not sure how I can evaluate if the current_user has a badge, (all the relationships are proper, I am only having trouble with my methods in my class (which should partially be moved into a lib or something), regardless, the issue is specifically 1) checking if the curre...
Right now I'm storing the user who last updated the state of my model in the state_last_updated_by_id field and the time the state was last updated in the state_updated_at field. Then I define methods like this: def published_at return unless state == 'published' state_updated_at end def published_by return unless sta...