So ive got a ActionMailer mailer
class ReportMailer < ActionMailer::Base
def notify_doctor_of_updated_document(document)
recipients document.user.email_id
from "(removed for privacy)"
subject "Document #{document.document_number} has been updated and saved as #{document.status}"
sent_on Time.now
bod...
Anyone have a good NTLM library recommend for Ruby?
There is http://rubyforge.org/projects/rubyntlm/ but it has not been touched in quite a while.
Update: I forgot to point out that I am looking for a client library. The service I want to use sits behind NTLM.
...
I'm compiling Ruby 1.9.1-p376 under Ubuntu 8.04 server LTS (64-bit), by doing the following:
$ ./configure
$ make
$ sudo make install
./configure works without complaints.
make hangs indefinitely until all my RAM and swap is gone. It get stuck after the following output:
compiling ripper
make[1]: Entering directory `/tmp/ruby1.9.1/r...
Here's part of my Note class:
class Note
attr_accessor :semitones, :letter, :accidental
def initialize(semitones, letter, accidental = :n)
@semitones, @letter, @accidental = semitones, letter, accidental
end
def <=>(other)
@semitones <=> other.semitones
end
def ==(other)
@semitones == other.semitones
end
...
Beginning Ruby Question:
I'm trying to see if a string variable's contents is either "personal" "email" or "password".
I'm trying:
if params[:action] == "password" || "email" || "personal"
foo
else
don't foo
end
But that doesn't work and returns strange results, and using IRB to play around with "or" statements I have no idea wh...
I have the following code:
class Like < ActiveRecord::Base
belongs_to :site
validates_uniqueness_of :ip_address, :scope => [:site_id]
end
Which limits a person from "liking" a site more than one time based on a remote ip request. Essentially when someone "likes" a site, a record is created in the Likes table and I use a hidden fie...
I am wondering how I can order posts in my PostController#index to display by a column total in a separate table. Here is how I have it set up.
class Post < ActiveRecord::Base
:has_many :votes
end
and
Class Vote < ActiveRecord::Base
:belongs_to :post
end
I user can either vote up or down a particular post. I know there are li...
I want to use an equivalent of Oracle's nvl() function in Ruby. Is there a built in function or do I have to write one myself?
Edit:
I am using it to rewrite some sql to ruby:
INSERT INTO my_table (id, val)
VALUES (1, nvl(my_variable,'DEFAULT'));
becomes
plsql.my_table.insert {:id => 1, :val => ???my_variable???}
...
In my model example Game, has a status column. But I usually set status by using symbols. Example self.status = :active
MATCH_STATUS = {
:betting_on => "Betting is on",
:home_team_won => "Home team has won",
:visiting_team_won => "Visiting team has one",
:game_tie => "Game is tied"
}.freeze
def viewable...
I have a Lexicon model, and I want user to be able to create dynamic feature to every lexicon.
And I have a complicate search interface that let user search on every single feature (including the dynamic ones) belonged to Lexicon model.
I could have used a serialized text field to save all the dynamic information if they are not for se...
MySQL has a very nice option for INSERT statement, which is particularly helpful for join tables without the id column. It inserts a record, but, instead of throwing an error if its key clashed with the existing one, that record is updated. Here's an example:
INSERT INTO table (key1,key2,data) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE ...
Good afternoon all, I was trying to post an XML document via net/http to a url, though (I think) I've structured it well but it gives me an error"xml document structures must start and end within the same entity"
This is a copy of my code
require 'rexml/document'
include REXML
doc2 = Document.new
doc2.add_element("feed", {"xmlns" => "h...
When the p function is used to print out an object, it may give an ID, and it is different from what object_id() gives. What is the reason for the different numbers?
Update: 0x4684abc is different from 36971870, which is 0x234255E
>> a = Point.new
=> #<Point:0x4684abc>
>> a.object_id
=> 36971870
>> a.__id__
=> 36971870
>> "%X" % a....
This is deals_controller.rb. And it works like this, except two things.
Not sure how to call Deal.count to add in my flash[:notice] . I get the hunch that its not calling something global.
I need that contional statement back, as I'm pretty sure its responsible for actually adding the new @deal . So I assume my syntax is off. Do note, ...
I'm currently working with extremely large fixed width files, sometimes well over a million lines. I have written a method that can write over the files based on a set of parameters, but I think there has to be a more efficient way to accomplish this. The current code I'm using is:
def self.writefiles(file_name, positions, update_valu...
I am having problems with conflicting versions of Ruby that I have installed. I had 1.8.6 and then installed 1.8.7 and it has caused problems. I get the following error when trying to run my ruby on rails app:
/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version (1.8.6) doesn't match executable version (1.8.7) (RuntimeErro...
Hey all,
I am starting to create my sites in Ruby on Rails these days instead of PHP.
I have picked up the language easily but still not 100% confident with associations :)
I have this situation:
User Model
has_and_belongs_to_many :roles
Roles Model
has_and_belongs_to_many :users
Journal Model
has_and_belongs_to_many :roles
...
Could someone please add comments to this code? Or, alternatively, what would be the pseudocode equivalent of this Ruby code?
It seems simple enough but I just don't know enough Ruby to convert this to PHP.
data = Hash.new({})
mysql_results.each { |r| data[r['year']][r['week']] = r['count'] }
(year_low..year_high).each do |year|
(1....
I was working on a Rails template and was trying to write a bit of code that allows me to populate a table or multiple columns of ul tags "top-to-bottom" and "left-to-right" across however many columns I specify. I'm just getting the hang of Ruby so I couldn't figure this out. I'm also curious about an idiomatic Haskell version for this ...
Hi,
I have four models: Customer, QueueRed, QueueBlue, QueueGreen.
The Queue models have a one to many relationship with customers
A customer must always be in a queue
A customer can only be in one queue at a time
A customer can change queues
We must be able to find out the customers current position in their respective queue
In a...