I have a User model that acts_as_authentic for AuthLogic's password management. AuthLogic adds "password" and "password_confirmation" attributes over top of the db-backed "crypted_password" attribute. This is pretty standard AuthLogic stuff.
I want to have a method that sets both password and password_confirmation at the same time (usef...
I've actually figured out what causes this error, but Googling for it was unsuccessful so I thought I'd write it down here to help out other people. This error pops up when you've got an # -*- coding: undecided -*- comment at the top of one of your files. Emacs added this automatically for me, but re-saving the file caused it to be chang...
I'm trying my first application with mongodb on Rails using mongo_mapper and I'm weighing my options on an STI model like below.
It works fine, and I will of course add to this in more ways than I can currently count, I just curious if I wouldn't be better off with Embedded Documents or some such.
I'd like my models to share as much as...
I have a pattern in a couple of templates that's repeated. The code is for rendering a set of tabs and content for each tab.
Contents of /app/views/general/_product_groupings.html.erb
<table cellpadding="1" cellspacing="0" class="sub_container clear">
<tr>
<% first_visible_tab = true %>
<% @bundle.groupings.each do |group| %...
Given the following resource definition:
map.resources :posts, :except => [:show]
map.post '/:year/:month/:slug, :controller => :posts, :action => :show
I can make url_for work for me, using this syntax:
<%= link_to @post.title, post_url(:year => '2010', :month => '02', :slug => 'test') %>
But is there a way to make this work?
<%=...
How do I
download and
save
a binary file over HTTP using Ruby?
let's say for example the url is http://somedomain.net/flv/sample/sample.flv
I am on win platform and I would prefer not to run any external program.
...
We have a user whose mail account is deluged with spam. I'm suspecting that he fields a large number of email accounts and therefore is subject to more than he might be with only one or two addresses.
I want to knock up some code which will scan his mailbox and report on the number of addresses that were mailed to (ideally the ones whic...
n = 0
m = 40
o = 0
while n < m
n = n + 1
end
while n = m
o = o + 1
n = 0
end
With that code, what would be the best way to make it so once it went through the second loop it would go back through the first???
Any help for this beginner is welcomed. :)
...
I am using apn_on_rails for iphone push notification with rails.
Right now, the validation on token is no longer valid because the validation requires a space every 8 characters:
validates_format_of :token, :with => /^[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}$/
http://github...
Hello All,
I shot a find query to include certain models in rails but i want to order the included models by my custom criterion. I have shot the query like the following to fetch the qualifications associated with the user ordering the qualifications by the start_date:
@user = User.find @current_user.id, :include => [:profile, {:...
Hi,
In ruby all classes are objects of class Class. Since classes are also objects, does a Ruby VM follow the same Garbage Collection strategy for class objects? What determines that a class object is safe for garbage collection?
Thanks
...
Hi,
I am currently developing a Rack-based application and want to redirect all file requests(e.g. filename.filetype) to a specified folder.
Rack::Static only supports file requests for a special folder(e.g. "/media").
Do I have to write an own Rack middleware or does a out-of-the-box solution exist?
Best regards
...
I'm using rails 2.3.5 and ruby 1.8.7. I'm building a simple TODO manager. Where I have tasks that belong to a user and a user has many tasks.
I'm using acts_as_taggable_on_steroids plugin for tagging tasks and restful_authentication plugin for registration and user management.
I'm getting a weird error that reads "Can't dup NilClass" ...
What are these variables?
Class User
TOTO = 1
TITI = 2
end
User::TOTO # 1
User::TITI # 2
any links to the doc?
Thanks,
...
I have a method which scans plain text (specifically in the QIF format) looking for dates which occur after a 'D' on a new line:
dates = "D2009-11-12\nPApple Store\nMSnow Leopard\nD2009-11-13\nPApple Store\nMiMac".scan(/^\s*D"?(.+?)[\r\n?|\n]/m)
# => [["2009-11-12"], ["2009-11-13"]]
"D2009-11-12\r\nPApple Store\r\nMSnow Leopard\r\nD200...
How would I impelement a function, in ruby, such as the following?
change_me! (val)
update:
What I set out to do was this:
def change_me! (val)
val = val.chop while val.end_with? '#' or val.end_with? '/'
end
This just ended up with....
change_me! 'test#///' => "test#///"
...
So how can I still be able to write beautiful code such as:
'im a string meing!'.pop
Note: str.chop isn't suffecient answer
...
I'm trying to figure out how to replace a quote like ' with something like \'.
How would I do this?
I have tried
"'".gsub("'","\\'")
but it just gives an empty string. What am I doing wrong here?
...
I am saving a raw email in a TEXT column in MySQL with Ruby on Rails. It keeps getting truncated to 65535 characters, does anyone know what causes this?
MySQL is running with
max_allowed_packet=64M
...
I'm trying to get a compile command (rake cucumber) to run with a specific ruby version on my Mac OS X system, I use rvm to do this currently in the terminal. My ~/.MacOSX/environment.plist has the correct path in it, but emacs insists on prepending to this path and therefore making it useless. I've also tried:
(when (equal system-type...