Ruby is an open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in 1993.
0
votes
0answers
3 views
Tux with Sinatra cannot load
Pretty new to Sinatra, but I am following this tutorial to set up a simple blog site with some static pages: http://danneu.com/posts/15-a-simple-blog-with-sinatra-and-active-record-some-useful-tools/
...
0
votes
0answers
9 views
show filenames with blank spaces and other symbols in views
im have this code to save scrapping images with nokogiri and mechanize:
img_url = agent.page.at(".field-content a")[:href]
root_img_url = URI.join(page_url,img_url).to_s
cover = ...
0
votes
0answers
6 views
Nokogiri get xpath from Nokogiri::XML::Element
How to get xpath for rc an element returned by search
f=File.open('/media/cc.xml')
doc = Nokogiri::XML f
rc = doc.search('realmCode')
[#<Nokogiri::XML::Element:0x15a4d714 name="realmCode" ...
0
votes
0answers
4 views
How to avoid Called 'load' without the :safe option — defaulting to safe mode warning?
When i start thin server i get the following
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown ...
0
votes
1answer
18 views
calling a method in a model from another controller in rails 3
In my rails application I need to call a method defined in one table from another controller. There are two tables named coordinates and tweets. The condition for the tweets table is decided by the ...
0
votes
0answers
6 views
What are OPTIONS, LINK and UNLINK routes in Sinatra?
Sinatra routes documentation is too short:
options '/' do
.. appease something ..
end
link '/' do
.. affiliate something ..
end
unlink '/' do
.. separate something ..
end
I've been ...
0
votes
2answers
12 views
How to add an empty attribute in rails form_for tag?
To make foundation validations work, I have to add the 'data-abide' attribute to form tag like this :
<form data-abide>
How can I do this using the form_for tag in rails?
The full rails code ...
0
votes
0answers
11 views
Crawl coursera courses data with ruby
I want to get a list of courses from coursera.org. I tried with the following ruby snippet
require 'wombat'
Wombat.crawl do
base_url "https://www.coursera.org/courses"
path "/"
headline ...
0
votes
0answers
9 views
Parse a recipe and determine if gluten free
I have been assigned an application where a user types in ingredients for a recipe and I try and figure out things like if the recipe is vegan, vegetarian, or gluten free. I'm trying to figure out how ...
0
votes
0answers
11 views
mongodb aggregation using $sum and $sort in mongoid
This code works fine in mongodb shell:
db.orders.aggregate({$unwind: "$picklist"}, {$group : {_id: "$picklist.sku", qty: {$sum : "$picklist.quantity"}}},{ $sort : { qty : 1}})
I thought conversion ...
1
vote
3answers
43 views
Why does && in Ruby sometimes shortcut evaluates and sometimes doesnt?
I want to test if an element in a hash exists and if it is >= 0, then put true or false into an array:
boolean_array << input['amount'] && input['amount'] >= 0
This raises no >= on ...
0
votes
1answer
13 views
Navigation bar works on first link, but when other links are clicked items disappear
I am trying to list out a side navigation bar. The navigation should say video, followed by step 1, step 2, and step 3. It works and displays properly, but strangely, once I go to step 1 from ...
0
votes
0answers
7 views
PUT method return 405 in RSpec test for API
I am building RESTful web server using Goliath-Grape and using RSpec for TDD. When make the API PUT call (/api/v1/users/:id) to update an existing record from the browser I get the expected 204 ...
0
votes
1answer
14 views
How to solve an error in Heroku's config/database.yml file “mapping values are not allowed in this context”
I'm deploying an app to Heroku and it's mostly fine but for this error
mapping values are not allowed in this context at line 22 column 13 (Psych::SyntaxError)
The line they are referring to is ...
0
votes
1answer
16 views
Gracefully handling NoMethodError on associations
What is a nice way of handling NoMethodError's on associations?
For example, let's say I hit a URL like http://mysite.com/orders/ID_THAT_DOESNT_EXISTS/payments, I would get an exception complaining ...