Hi !
I'm currently working on a Rails app which stores plain clear passwords (...). So I'm migrating to Authlogic authentication with a 'standard' SHA512 encryption.
I did that which works fine :
#file /models/user.rb
class User < ActiveRecord::Base
acts_as_authentic { |c|
c.transition_from_crypto_providers = [MyOwnNoCrypto, Au...
Hi!
I want to reformat some helpers in my Rails views. I want to archieve a syntax similar to:
<%=
box :option => 'value' do |b|
b.header "Header of box #1"
%>
Content of Box#1
<%
end
%>
The b.header call is optional.
How would I structure my code to allow this? I guess it's something similar to fields_for in Rails.
Tha...
Ruby definitely stores such information at runtime, as it is printed in stack traces - but there doesn't seem to be any obvious way of accessing it. Is there a solution? (other than grepping the sources, or passing nonsense arguments to method in hope of getting the stack trace)
...
I'm making a gem for internal use. In it, I load some YAML from another directory:
# in <project_root>/bin/magicwand
MagicWand::Configuration::Initializer.new(...)
# in <project_root>/lib/magicwand/configuration/initializer.rb
root_yaml = YAML.load_file(
File.expand_path("../../../../data/#{RootFileName}", __FILE__))
# in <project_r...
Hi all.
How to set several cookies in one GET-request from Ruby ?
Tnanks in advance.
...
I've been developing Rails apps now for about a year and am starting on a new project (that's actually 3 projects). I'd like to write some gems that can be shared amongst these projects to maintain a common code-base. They'll likely eventually evolve into Rails engines at some point, but to start, just common libraries that can be incl...
there are 2 ways to write validations in RoR3.
validates_length_of :name, :minimum => 5
validates :name, :length => { :minimum => 5 }
both will give the same.
i wonder where i can read more about the latter one. all the options for it.
cause the http://guides.rails.info/activerecord_validations_callbacks.html just mention th...
I'm designing a basic sports application in RoR and I don't know if my database design is correct. For instance, I have:
class Game < ActiveRecord::Base
has_one :home_team
has_one :away_team
end
class Team < ActiveRecord::Base
has_many :games
end
However, someone told me the better way to do this is:
class Game < ActiveRecord:...
So I have a string in ruby that is something like
str = "<html>\n<head>\n\n <title>My Page</title>\n\n\n</head>\n\n<body>" +
" <h1>My Page</h1>\n\n<div id=\"pageContent\">\n <p>Here is a para" +
"graph. It can contain spaces that should not be removed.\n\nBut\n" +
"line breaks that should be removed.</p></body></ht...
I am running a bit of code that looks like this:
result = system("ruby " + filename_random_ruby_script)
if result
save_to_disk(random_ruby_script)
else
# Do Nothing
end
The variable "random_ruby_script" represents any .rb file.
This code is the first of many calls to system() and runs a ruby file that may also contain calls to sy...
Hi All
I'm just starting to learn my way around CouchDB and Sinatra, but am struggling to find some basic examples of integrating the two via CouchRest. The CouchRest docs assume a little too much to be useful to me yet.
Does anyone have links to useful examples/articles/docs?
...
Hey,
I have a form where users can enter an isbn and it will try to lookup book data and save it.
When validation fails for the isbn lookup (for example if somebody entered it incorrectly), I would like it to redirect to another form where users can enter data in manually if the isbn lookup fails (but not if other validations like numer...
Hi all,
I'll admit I'm still new to Ruby and now mongoDB so i'm guessing i'm doing something dumb.
For a test I have this code called tester.rb:
require 'Mongo_Mapper'
MongoMapper.database = "myTestDB"
class Person
include MongoMapper::Document
key :first_name, String
key :last_name, String
end
person = Person.new(:first_name =...
Ruby enthusiasts! I am trying to write a DSL in ruby and i would like to be able to create some magic methods (not sure that is the most accurate term for what i want).
I would like to be able to do things like the following:
a = [1, 2, 3]
b = 2
(a contains b)
And have it resolve to true or false.
Essentially, how can i define the f...
Hi All
I'm working on my first Sinatra/CouchDB project and I'm getting an error I can't explain.
Here's my rackup (config.ru) file:
require 'rubygems'
require 'couchrest'
require 'patina'
set :environment, :development
set :root, File.dirname(__FILE__)
set :run, false
FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new...
How does the default TimeZone get set in ActiveSupport?
Here's what's happening:
irb -r 'rubygems'
ruby-1.8.7-p174 > require 'active_support'
ruby-1.8.7-p174 > require 'active_support/time_with_zone'
ruby-1.8.7-p174 > Time.zone
ruby-1.8.7-p174 > nil
How do I set that to the current location by default?
...
This seems like a fairly simple problem to me but I have been having some issues.
In one of my views I use something like
<% if current_page?(:controller => "activities", :action => "new") %>
*Do something here*
<% end %>
and it does something specific on the new page for a form. Easy enough and it works great.
Unfortunate...
Hi
I've recently started working on my first Sinatra/CouchDB app and kept running into a SystemStackError: stack level too deep error. After a ton of googling, I've discovered that one of the gems I've been using, json-1.4.3, is apparently broken :/
I uninstalled the gem, and installed json-1.4.2 instead, but I'm still getting the erro...
ActiveRecord gives you an interesting error when you try to eager-load a non-existent association. It looks something like this:
ActiveRecord::ConfigurationError: Association named 'secondary_complaint' was not found; perhaps you misspelled it?
Now why the hell would anybody want to preload a non-existent association? Check this out.
...
Hi,
I have been designing small and simple sites for years now, I have somehwat experience of PHP but I have good grasp over HTML and CSS and on Wordpress.
Now, I want to try my hand on Ruby on Rails as well, just to get a hang of it and to be able to edit pre-written code.
Please help me where to start and what to learn first, includ...