How does one remove trailing character correctly in the following sentence if it's in config/environment.rb file.
KEY = ENV['KEY'].delete "\r"
It produces the following error:
undefined method `delete' for nil:NilClass (NoMethodError)
It works well in IRB, but not in environment.rb
Solved
Aptana Studio 3 stopped to load .bashrc a...
When I Ctrl C my program on linux I often get output that looks similar to a stack-dump (a crash).
Can I catch the Ctrl-C signal and exit gracefully?
Thanks!
...
I am using the MySql class in ruby with MySql.real_connect etc.
Is there a method to set the mysql charset just like mysql_set_charset in php?
...
I have installed the gem 'simple_uuid' but nothing seems to be working.
Using irb and running the following:
require 'rubygems'
require 'simple_uuid'
is fine, both return true. But running the following:
// Class added by simple_uuid
UUID.new
returns
NameError: uninitialized constant UUID
from (irb):3
from :0
I'm a rub...
I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world.
The application is a classic client server with detailed forms for each business entity.
It will be taking user input, do some validation checks, a few calculations, and save them to database.
It will also have list...
I'm using will_paginate as standard, but it only shows the pagination controls (< 1 2 > etc) when there's more than one page to display. Normally, this would be what is wanted, but I want to see the pagination controls (for UI consistency and to get round an annoying CSS quirk in the system I'm working on) even when there's only 1 page t...
I'm working through a book on Ruby, and the author used a slightly different form for writing a class initialization definition than he has in previous sections of the book. It looks like this:
class Ticket
attr_accessor :venue, :date
def initialize(venue, date)
self.venue = venue
self.date = date
end
end
In previous sec...
I'm having a hard time getting Sinatra running on my local setup, Ubuntu Karmic 9.10. The error getting thrown when I have require 'sinatra' is:
NoMethodError: undefined method `[]' for nil:NilClass
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:891:in `compile'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/...
I have a Ruby class called LibraryItem. I want to associate with every instance of this class an array of attributes. This array is long and looks something like
['title', 'authors', 'location', ...]
Note that these attributes are not really supposed to be methods, just a list of attributes that a LibraryItem has.
Next, I want to mak...
I have the need to do the following in Rails to mirror a desktop application:
a User and an Office 'owns' a record, if you don't own the record on a user or office level you're kicked into the public realm.
user gets read,write,delete to the model record
office gets read/write/delete to the model record
other or public gets read/write/...
Hello,
I know that question with same title has been asked almost 6 month ago.
I have Googled for this problem and I have not found any working solution.
Has there been any fixes for this very critical problem?
I need to get my website running ASAP. Just to get the site up and running I'm even ready to add utf8 conversion methods to ...
I'm using webrick (the built-in ruby webserver) to serve .rhtml
files (html with ruby code embedded --like jsp).
It works fine, but I can't figure out how to access parameters
(e.g. http://localhost/mypage.rhtml?foo=bar)
from within the ruby code in the .rhtml file.
(Note that I'm not using the rails framework, only webrick + .rhtml fil...
Quite-probably a silly question, as I don't know much about Java/Jython/JRuby/bytecode, but..
I stumbled across _why's unholy again today.. It allows you to output Python bytecode from Ruby code.. Basically allowing them to produce the same bytecode..
Jython outputs Java bytecode, as does JRuby.. Since these both compile to the same by...
Hi, anybody, please, help me with Thinking_sphinx configuration.
I have table profile1, which has_one profile2 and profile3.
So i just need to index them both, but i can't.
I tried
indexes name
indexes profile2(:name), :as => :profile2_name
indexes profile3(:name), :as => :profile3_name
has id
What i m doing wrong?
Thanks.
...
Hello,
I would like to convert a raw string to an array of big-endian words.
As example, here is a JavaScript function that do it well (by Paul Johnston):
/*
* Convert a raw string to an array of big-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binb(input)
{
var output = Array(input.lengt...
I'm using periodically_call_remote to update a portion of a page that contains a list of objects. I send along with the url a param containing the created_at date for the most recent object in the database. The action that is called then get all the objects that have been created since then and renders a partial which displays them at th...
If you were going to develop a game in say, Ruby, and you were provided with a game framework, would you rather act on key up/down events by overloading a method on the main window like so:
class MyGameWindow < Framework::GameWindow
def button_down(id)
case id
when UpArrow
do_something
...
Hi!
Is it good when url to show and destroy are same? How it can be changed in RoR if i want continue use standard tools like script/generate scaffold ?
Thanks.
...
I'm attempting to sum daily purchase amounts for a given user. @dates is an array of 31 dates. I need the find condition to compare a date from the array to the created_at date of the purchases. What I'm doing below compares the exact DateTime for the create_at column. I need it to look at the day itself, not the DateTime.
How can I wr...
I am trying to bind to an Active Directoy server using Ruby Net::LDAP, like so:
Net::LDAP.new(:host => "...", :port => "...", :encryption => :simple_tls,
:auth => {:method => :sasl, ...
But I'm not sure how to specify they username and password. I can't seem to find any examples of using sasl. How do I specify my credent...