My sort function is clearly not working, I am trying to sort ALL_VIEWS by @permalink.length:
ALL_VIEWS.sort_by {|view| view.permalink.length}
ALL_VIEWS[0..4].each do |view|
puts view.inspect
puts view.permalink.length
end
this produces:
#<View:0x1014da7b8 @permalink="xxxx">
4
#<View:0x1014da790 @permalink="yyyyy">
5
#<View:0...
OK I am pulling my hair after trying this out too many times to debug.
So pls pls help me out here
I keep getting 401 Unauthorized error after I am redirected back.
Here is my code
What am I doing wrong here?
require 'rubygems'
require 'OAuth'
require 'json'
class SessionController < ApplicationController
before_filter :load_o...
Im trying to use this jquery ui widget for autocompleting a textbox in my app.
I have created an index.json.erb file inside my views/university folder
here's my current (piece of crap) code
json='['
<% @universities.each do |u| %>
json+='{ "id": "#{@u.name}" , "label":"#{@u.name}" , "value": "#{@u.name}"},'
<% end %>
json+=']'
json
N...
Im trying to figure out the best way to map simple routes into one url. Application contains of 4 models: Location, Category, Budget, Company. But each model could be mapped to single url like this. For real-world example you can check out http://sortfolio.com/
/chicago <- Location
/3k-5k <- Budget
/bars <- Category
/company-name <- Com...
The problem:
I have a collection of people, I want to have a revise.html page that allows me to increment a integer on all the people.
if I make a new method in the people_controller it auto sends me to people/revise.. which gets interpreted as show/revise... which is not an id.
I understand this happens because of REST constrictions....
I'm trying to parse out some log files with ruby. I have plenty of experience with regexes but the other day I was using rails routes and thought that might be a really neat way to parse out these log files because it would be incredibly easy to understand the parser. Regex, on the other hand, takes several minutes for most people to d...
I was wondering:
In python, canon says to use buildout or virtualenv, to avoid installing into the system packages. It's second nature now, I no longer see anything ludicrously bizarre to the practice. It makes a kind of sense.
In Ruby, is there something similar? How does ruby deal with this problem? Does ruby have this problem?
...
My boss wants me to develop an application very similar to an accounting system (that will be a part of another big system, written in ruby (using rails) and javascript (using extjs))
How can I start?
For example, I had a plan to use mongodb for our system, but now I'm not sure because of luck of transactions and ACID in mongodb.
Wh...
Hi guys!
So after a couple of months of development today I am finaly deploying!
(WOOHOO great day).
But i am stuck with a problem I can't seem to fix:
First of all in development all is working perfectly.
In deployment on my server it isn't though!. I use attachment_fu and i
am able to upload
pictures but the pictures are not resizing...
I'm trying to recalculate percentages in an after_update callback of my model.
def update_percentages
if self.likes_changed? or self.dislikes_changed?
total = self.likes + self.dislikes
self.likes_percent = (self.likes / total) * 100
self.dislikes_percent = (self.dislikes / total) * 100
self.save
end
...
Hey,
given this code:
class A
CONST = 'A'
def initialize
puts CONST
end
end
class B < A
CONST = 'B'
end
A.new # => 'A'
B.new # => 'A'
I'd like B to use the CONST = 'B' definition, but I don't know how. Any ideas?
Greetings
Tom
...
I can't find any useful resources online that breaks down Ruby's different flow-control options.
Let's assume that I'm iterating over an array within in a method:
def a_method
things.each do |t|
# control options?
end
end
What are my different flow-control options here? How do they differ?
retry
return
break
next
redo ...
I have a Mix-in that reflects on the receiver class to generate some code. This means that I need to execute the class method at the end of the class definition, like in this trivially dumbed down example:
module PrintMethods
module ClassMethods
def print_methods
puts instance_methods
end
end
def self.included(rece...
I primarily work in PHP and prefer to do so since there seem to be more jobs in this language, at least in my area (and I'm still fairly new to it so I want to continue to learn the language better).. but for some things I want to do I need to use the WWW Mechanize library that doesn't work with PHP but does with Ruby (yes I know PHP has...
Im trying to define an array of arrays as a Constant in one of my classes, the code looks like this:
Constant = [[1,2,3,4],
[5,6,7,8]]
When I load up the class in irb I get:
NoMethodError: undefined method `[]' for nil:NilClass
I tried using %w and all that did was turn each one into a string so i got "[1,2,3,4]" inste...
I'm having trouble runnng rspec2 and rails. Here's my log:
1) TrackController home path should be /track
Failure/Error: Unable to find C to read failed line
undefined method `route_for' for #<#<Class:01x5ffe7c2f>:0x77d36efb>
# ./spec/controllers/track_controller_spec.rb:5
# :1
Here's my spec:
describe UsersController,...
I've been searching on this but haven't found anything decisive so far.. I already have a windows WAMP server up and running and am using it for my PHP apps, I want to be able to run some small ruby scripts (to interact with a library that is not available in PHP), I don't even need Rails at this point, I just want to run ruby scripts an...
Hi,
I'm having some troubles with my Rails app after installing (and removing) Compass. bundle install gives me the following:
/Users/[..]/.rvm/gems/ruby-1.9.2-head@rails3beta/gems/bundler 1.0.0.beta.2/lib/bundler/settings.rb:10:in `[]': undefined method `[]' for false:FalseClass (NoMethodError)
from /Users/[..]/.rvm/gems/ruby-1.9.2-he...
Sorry to ask such a general question as I'm sure a lot of questions have been asked before about IDE's... but I specifically have major problems running IDE's that are written in non-native languages for Windows (like Java), NetBeans gave me horrible performance and I just tried Aptana and got a similar issue...
I have a fast computer (...
I'm trying to make a simple room management service. The rooms have these properties:
class Room
include DataMapper::Resource
validates_is_unique :number
property :id, Serial
property :number, Integer
property :guest, String
property :status, Enum[ :free, :occupied ], :default => :free
end
Then I create a new room like th...