I'm using the Devise Ruby gem in my Ruby on Rails 3 application. When a logged in user creates one of my models, I want to save their user id as the person who created it. What should I do?
...
Whenever I make a open or save and erb file. I get this error. No idea how to fix it
Error detected while processing function <SNR>59_UpdateErrors..<SNR>59_CacheErrors..SyntaxCheckers_eruby_GetLocList..SyntasticMake:
Line 20:
E40: Can't open errorfile ~\AppData\Local\Temp\VIeF751.tmp
...
I'm creating this little show scheduler thing.
I have the table shows, with title:string and description:text. I want to add days and times to the show (each show can have multiple days, and each day has their OWN times). How might I go about doing this?
I was thinking of making a times table. With the columns (show_id, day, and time)....
Hi
I have an object with an attribute called value which is of type big decimal. In the class definition i have validates_numericality_of.
However if i:
a.value = 'fire'
'fire' ends up getting typecast to the correct type before the validation fires so:
a.valid? => true
How do get the validation to fire before the typecast?
Th...
I am getting a segmentation fault. Should which ruby return /usr/local/bin?
rpi-wl-757:ellisberner maletor$ rails generate mailer ContactMailer
/Users/maletor/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.4/lib/mysql2/mysql2.bundle: [BUG] **Segmentation fault**
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Abort trap...
require 'rubygems'
require 'mysql'
class Analyse
def self.get(from,to)
open('/tmp/result','w') do |wfile|
dbh = Mysql.real_connect("localhost", "root", "******")
dbh.query("use stock;")
result=dbh.query("select symbol,date,open,high,low,close from `#{symbol}` where (date > from and date< to) order by date asc;")
compute=[]
resul...
i have this string
[url=test.php]test[/url]
or
[url=http://test.php]text[/url]
I want to a regex get this
[url=http://test.php]text[/url]
example:
before:
str = "[url=test.php]text[/url]"
str.gsub(/\[url=(.*?)\](.*?)\[\/url\]/,'[url=http://\1]\2[/url]')
=> "[url=http://test.php]text[/url]"
question:
str = "[url=http://test....
Does IDEA support all the features of rubymine, or is rubymine more refined for rails and IDEA doesn't have all the rubymine features?
...
Hi, I have this code in C that use openssl library to calculate the SHA1 digest of a bignumber.
How I can translate this code in Ruby?
#include <stdio.h>
#include <openssl/sha.h>
#include <openssl/bn.h>
int
main ()
{
// Create a bignum = 3
struct bignum_st *bn = BN_new ();
BN_set_word (bn, 3);
// Initialize SHA1 contex...
Hi,
I have model with custom primary key:
document.rb
class Document < ActiveRecord::Base
set_primary_key "token"
end
routes.rb:
MyApp::Application.routes.draw do
resources :documents, :only => [:index, :show, :create]
end
When i create new document, i get error:
No route matches {:controller=>"documents", :id=>#<Document id:...
Is the timezone difference always ignored, regardless in which zone the time is expressed in?
Intuitively, the number of seconds passed since EPOCH should be higher for those who are, for example, in UTC+2. However, this seems not to be the case.
...
It tells me I have bad syntax on the line:
rsync -a --delete #{DIR_DATA}/ #{todays_folder}/
Here's the entire program:
#!/usr/bin/ruby
require 'rubygems'
require 'fileutils'
DIR_DATA="/mnt/apvdbs03/Public"
DIR_BKUP_ROOT="/backs/apvdbs03"
NUMBER_OF_BACKUPS = 7
def remove_last_backup_folder
last_backup_folder = File.join(DIR_BKUP_ROO...
Is there a method that let me compare one String with multiple others in Ruby? I really would like to do something like this:
myString.eql?(["string1","string2","string3"])
...
Hi,
I have just installed rvm today and it looks really handy/powerful.
I think I am getting the hang of it, but...
When using an rvm installed ruby, and running irb, when I require an installed gem, something, like 'rvm', I get:
> kimptoc$ rvm use 1.8.7
Using /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302
> kimptoc$ gem list
*** LOCAL ...
Lets say we have a simple model that stores two integers, the min and the max. We would like to force min <= max.
class MinMax
include MongoMapper::Document
key :min, Integer
key :max, Integer
validate_presence_of :min, :max
end
1) How would you validate that min is indeed equal or less than max?
2) If you don't think this ...
Also known as the <<"User has many Databases" question.>>
The environment
My app is modeled like so:
user has_many databases
database has_many tables
table has_many rows
row habtm(+value) columns
you get the idea!
So instead of modelling a database inside a database,
I would like to have:
a sqlite3 database that h...
Im trying to build Qpid. When running CMake this is printed to the log:
Could NOT find Ruby (missing: RUBY_LIBRARY)
[ ... more stuff cut for brevity ]
CMake Error at src/CMakeLists.txt:96 (include):
include could not find load file:
C:/qpid/0.6/qpid/build/src/rubygen.cmake
It seems to be failing because it couldnt find a fi...
In Rails, you can create an anchor tag that spans multiple lines doing something like the following:
<% link_to target_url_path do %>
<span class="title">Example</span>
<span class="excerpt">Neque porro quisquam est qui dolorem ipsum...</span>
<%= image_tag 'example.png', :class => 'thumbnail' %>
<% end >
I'm wondering how...
I am using prawn to generate a pdf form and I need to change the font size for the labels of the fields OR change the headers font size.
...
So I'd like to be able to add a longer block of text to a YAML locale file in Rails.
However, the YAML parser gives syntax errors for blocks that appear to be fine! I've read through the Ruby YAML cookbook and it seems like these examples below should all work, but they don't.
config/locales/tx.yml
This one works fine:
tx:
states:
...