How do you clear a single entry from a ruby on rails session ?
In ruby on rails when doing session[:foo] = nil it leaves an entry named :foo in the session object. How can you get rid of that single entry from the session object? ...
In ruby on rails when doing session[:foo] = nil it leaves an entry named :foo in the session object. How can you get rid of that single entry from the session object? ...
I need to do a fairly extensive project involving web scraping and am considering using Hpricot or Beautiful Soup (i.e. Ruby or Python). Has anyone come across a tutorial that they thought was particularly good on this subject that would help me start the project off on the right foot? ...
Hi all, I am creating what I expect to be ruby gem. Anyone have a good link to a tutorial on converting a simple library or plugin to a gem? Also, especially, what is the process that Ruby uses to allow the require to find gems? It seems to be something more than putting the files in the gem path (or is my configuration screwed up?). ...
I have a user registration form, and wanted to write a human detecting "captcha" into my register method. I decided to create a simple math question for users to answer (this should work for my purposes). How do I write a validation that checks the value of this field? I wrote a validate method in my model file as follows: def validat...
I have a model and I would like to store ids of associated objects (denormalize) for performance reasons. I have a method which looks like this: def cache_ids self._tag_ids = self.tag_ids end I thought I could just run it on before_save, however there is a problem - some of the associated objects might be new records, and therefore ...
Rails provides a very useful console ('script/console'). I write a ruby file and run it in the console using require foo.rb. It works fine the first time, but the second and next require foo.rb does not run my script (require does not reload it). Do you have any tips/tricks? ...
Took me a while to track down this error but I finally found out why. I am modeling a card game using the Rails framework. Currently my database looks (mostly) like this: cards cards_games games ----- ----------- ----- id id id c_type card_id ... value game_id other_stuff ...
I am developing a Windows application using Ruby. What is the best GUI editor for Ruby? ...
I was wondering if anyone knew of a particular reason (other than purely stylistic) why the following languages these syntaxes to initiate a class? Python: class MyClass: def __init__(self): x = MyClass() Ruby: class AnotherClass def initialize() end end x = AnotherClass.new() I can't understand why the syntax used f...
Is it possible to make some kinda this association: User model: has_many :goods, :through => :assignments has_many :goods_want, :through => :assignments, :source => :good, :conditions => "assignments.type = 1" Testing in console u = User.first u.goods_want << Good.first u.save This is being logged: INSERT INTO `assignments` (`goo...
I simply want my method call to suppress all "NoMethodError" exceptions that might arise in the methods it in turn calls. def foo begin bar1 bar2 rescue Exception return '--' end end But this doesn't work. NoMethodError keeps being raised to the top level. The exact error is undefined method []' for nil:NilClass' (...
I often hear about Flex being combined with web frameworks on the backend. The idea being that Flex serves as the presentation framework while the web framework (Django/Rails) does the database lookups and sends the data to Flex to present in the form of XML. However, is there ever a situation where Flex and Python/Ruby would be combine...
This is my Action model: class Action < ActiveRecord::Base end class Fold < Action end class Check < Action end class Call < Action end class Bet < Action end In another model, I have this class Deal < ActiveRecord::Base def Deal.parse_action(action_string) case action_string when "folds": Fold.new() when "checks"...
So ive got this big-ass collection right? Its tree-backed(RBTree), so look-ups are fast, and the values are sorted. Say ive got value X. I can look up X in my tree in logn time, cool. But I want the values to the right of X in the tree as well, until one of them dosent satisfy a test. Ie, get all elements that are >= X and < Y I could ...
Only certain users can no longer receive notifications from my app. I was able to re-produce this with a test account but I dont know how and removing/adding the application doesn't seem to fix the problem. This application is only being used by 4-5 testers and the number of notifications being sent to any given user is very nominal and...
In ruby on rails, all has_many :widgets methods generate both a object.widgets method and an object.widget_ids method. The latter method is very useful because it bypasses the creation of ActiveRecord objects and runs a much faster query. The query speed can be improved by using the :select option, but ruby still allocates much more mem...
This regards the ruby ORM library DataMapper. This wiki describes how to use the in_memory adapter for DataMapper. The proper database adapters saves an incrementing, unique id on each model instance - in_memory doesn't seem to do that as shown by the following snippet: require 'rubygems' require 'dm-core' DataMapper.setup(:in_memory,...
I'm implementing a forum system called rBoard. Code is viewable at http://github.com/radar/rboard. I've reached an impasse with the permissions code that I've been trying to implement and I've decided to turn to the all-knowing, ever-caring Stack Overflow to solve this issue. Relevant information is thusly: Category model class Catego...
I'm looking for a general purpose syntax highling library, to output to html. It's for use within a ruby app, so a ruby library would be good, but an excellent utility which can be piped in and out of would do Also needs to guess the appropriate language to highlightsy by itself ...
I'm working on script right now which has to run each ruby script in a directory and its subfolders. e.g. run-all.rb - scripts - folder1 - script1.rb - script2.rb - folder2 - script3.rb - script4.rb As the server is a Windows server I would normally use a batch file but the head dev insists everything must be don...