hello!
i have a user and an admin role in my project. i created my authentification with devise, really nice and goot tool for handling the authentification. in my admin role i don´t have any confirmation or something like that. it is really simple and doesn´t make problems. but in my user model i have following things:
model:
devise ...
How can I perform bitwise operations on strings in ruby?
I would like to do bitwise & a 4-byte string with a 4-byte long hex such as ("abcd" & 0xDA2DFFD3). I cannot get the byte values of the string. Thanks for your help.
...
I'm searching for a definitive document on Ruby syntax. I know about the definitive documents for the core API and standard library, but what about the syntax itself? For instance, such a document should cover: reserved words, string literals syntax, naming rules for variables/classes/modules, all the conditional statements and their per...
The following code snippet works fine in 1.8.7 on Mac OS X, but not in 1.8.6 on Ubuntu. Why? Is there a workaround?
Works in 1.8.7:
$ ruby --version
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
ltredgate15:eegl leem$ irb
>> 6.times.map {'foo'}
=> ["foo", "foo", "foo", "foo", "foo", "foo"]
>>
But not in 1.8.6:
# ruby...
Is it possible to override the to_sentence method just for one model in my rails application?
More generally, how do I modify methods for an Array of my models?
...
I am working with ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux] and I get
undefined method `bytes' for #<String:0x2a95ec2268> (NoMethodError)
even though my code works on ruby 1.8.7. patchlevel 249
I saw somewhere that you need to add require "jcode" for a similar method not defined error with each_byte. I tried adding that but...
I'm still trying to get a handle on Cocoa (both in Obj-C and MacRuby), and I'd really appreciate seeing how to download a file with ASIHTTPRequest (or without it) and MacRuby. Ideally, I'd like to be able show the progress inside a progress bar too.
Must use a cocoa method for downloading, since open-uri in MacRuby is borken.
Thanks fo...
Can someone shed light on how to setup by_star gem: https://rubygems.org/gems/by_star?
I ran ruby script/plugin install git://github.com/radar/by_star.git.
However, when I went to call a by_star method in one of my models from console, I got an undefined method error.
Do I need include or require statement? Could I be missing depende...
More and more I'm putting all of my code in models and helpers concerning MVC.
However, sometimes I'm not sure where to organize code. Should it go into the model or should it go into a helper. What are the benefits of each. Is one faster or are they the same. I've heard something about all models getting cached so it seems then like th...
Here is the .rb program:
require 'watir'
b = Watir::Browser.new
the 2nd line will trigger a ""The program can't start because msvcrt-ruby18.dll
is missing from your computer!" error.
I am using 1.9.1p378 on win32
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]
How can I fix this? Thanks for your attention.
...
I have a table of events (in a sqlite3 database for what it's worth) with a column called "when" that contains a timestamp detailing precisely when the event that particular row denotes is set to occur. Right now, I have
@events = Event.find(:all)
in my controller and I am using template helper methods to calculate where to place eac...
here are sample lines
Apr 9 11:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred
some other log lines ..
....
Apr 9 12:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred
now the LATEST line would have to be one with the latest Date String, and THAT is the one that needs to be pr...
Hi
(Ive looked at the other questions - none seemed to quite fit my problem.)
I have some file-names under Windows 7 that need to be translated in to MySQL database (UTF-8) with Ruby on Rails.
An example file-name includes "íéó" in some kind of Windows 7 file-system encoding.
Ive tried many combinations of gsub and ActiveSupport::Mul...
This is going to be a really dumb question, I just know it, but I'm going to ask anyways because it's driving me crazy.
How do I get acts-as-taggable-on to work?
I installed it as a gem with gem install acts-as-taggable-on because I can't ever seem to get installing plugins to work, but that's a whole other batch of questions that are ...
Hey all,
I'm trying to use the scriptaculous helper method sortable_element to implement a drag-and-drop sortable list in my Rails application. While the code for the view looks pretty simple, I'm really not quite sure what to write in the controller to update the "position" column.
Here's what I've got in my view, "_show_related_pgs.e...
def singleton_class
class << self
self
end
end
class Human
proc = lambda { puts 'proc says my class is ' + self.name.to_s }
singleton_class.instance_eval do
define_method(:lab) do
proc.call
end
end
end
class Developer < Human
end
Human.la...
I used to be a developer in Java, PHP, perl and C/C++ (the C++ bit badly - the others not too badly, I hope).
This was back in the Java 1.3/1.4 days. We used raw JDBC, swing, servlets, JSP and ant (sometimes even make). Eclipse was new.
Then I joined a deployment team and became a deployment engineer and then after the deployment engin...
In the effort to learn python and/or ruby, I was wondering how a file shredder would be implemented? I would like it to take in a file as an argument and then employ an algorithm to make that file unrecoverable. Would possibly add the support for multiple files or even whole directories later.
...
I know this works
proc = Proc.new do
puts self.hi + ' world'
end
class Usa
def hi
"Hello!"
end
end
Usa.new.instance_eval &proc
However I want to pass arguments to proc. So I tried this which does not work. Can anyone help me make following work.
proc = Proc.new do |greeting|
puts self.hi + greeting
end
class Usa
def ...
I've searched for this a bit but I must be using the wrong terms - does ruby have a way to grep for a string/regex and also return the surrounding 5 lines (above and below)? I know I could just call "grep -C 5 ..."or even write my own method, but it seems like something ruby would have and I'm just not using the right search terms.
...