I'm trying to come up with a solution to this problem. I have a Ruby script that needs to run some PHP code, but I am new to Ruby, so I don't know how to go about doing this.
def run_my_code
#execute some PHP code here
# $person = new Person();
# $person->doSomething();
end
How can I achieve this?
...
I have created a common controller for my application.
class CommonController < ApplicationController
def index
# My stuff
end
end
And in my other controller i am using super to call my index method like this.
class Other1Controller < CommonController
def index
super
end
end
class Other2Controller < CommonController
...
Possible Duplicate:
What does ||= mean in Ruby?
what is ||= in ruby?
...
If your response in Sinatra returns an 'eachable' object, Sinatra's event loop will 'each' your result and yield the results in a streaming fashion as the HTTP response. However, if there are concurrent requests to Sinatra, it will iterate through all the elements of one response before handling another request. If we have a cursor to ...
Trying to follow along with a metaprogramming screencast from pragpub and ran into some problems because of changes in Ruby since the release of screencast.
Hard to explain the problem w/o the code, so here's that:
class Discounter
def discount(*skus)
expensive_discount_calculation(*skus)
end
private
def expensive_discou...
So I know I can add a filepath to a file element type using Watir, but is it possible to open up the file explorer to select a file to upload? Or is the only way to just enter the path using .file_fields?
...
Hi,
I am confused about how to access the attributes of an ActiveRecord instance from a method within the ActiveRecord instance.
For example I have a Lead class that inherits from ActiveRecord:
class Lead < ActiveRecord::Base
end
I have the following scaled down migration file that shows the columns of an ActiveRecord table:
class ...
Hi all,
I'm doing an application using mongodb and mongoid and I'm facing a problem where I need to map something in one document to something in another document. My plan is to store something in a document that I can then use to figure out what value for it to fetch from a different collection. But, this is more generally a ruby quest...
I want to push and pull things off of a stack in an atomic way using ruby and mongoDB.
The push I can do atomically via the following code example:
collection.update({"_id" => document["_id"]}, {"$push" => {field_name => value}})
Example code for pop:
value = collection.update({"_id" => document["_id"]}, {"$pop" => {field_name => -1...
ruby-1.8.7-p174 > [0,1][2..3]
=> []
ruby-1.8.7-p174 > [0,1][3..4]
=> nil
In a 0-index setting where index 2, 3, and 4 are all in fact out of bounds of the 2-item array, why would these return different values?
...
Hello,
I have a best practice/efficiency/performance issue.
If I want to have a profile page for each user in my system and i already have a user model. Is it better to have all the users information in the user model and pull it on the show page of users
so users/show will access the user model and grab all the relevant data like a...
I am using the restful authentication plugin in rails and i need to skip the authorization and log the user in immediately...How can this be done
Any ideas would be highly appreciated
...
when I run any rails command like rails s I get the following error:
Could not find diff-lcs-1.1.2 in any of the sources
Try running bundle install.
However, I already installed diff-lcs.
bundle show diff-lcs
/opt/local/lib/ruby1.9/gems/1.9.1/gems/diff-lcs-1.1.2
I also see diff-lcs when I do a gem list command
My GEM_HOME is /...
Hi,
I am trying to set up a preview button in an edit form based on the railscast by Ryan Bates. There are two buttons [edit] and [update].
When the user clicks the preview button, the "update" function in the controller is called. If I simply set the @article variable based on a find of the article table (as per below controller) th...
Relevant info
I have a User model with plenties of attributes and several has_many associations.
I have a BIG form to edite existing user info, including nested fields.
I have divided the form into several forms in different divs and show only one form at a time. (i.e. tabs in UI)
User can save info by clicking Save button, which subm...
Hello guys,
I am running Ruby 1.9.2. I have rake 0.8.7 installed. However running rake inside a Rails application gives me the following:
(in /usr/home/users/dimitar/Rails/spek)
Could not find activesupport-3.0.1 in any of the sources
Try running `bundle install`.
So I go ahead and run bundle install again and everything looks good:
...
I need to access GNOME keyrings from the Ruby programming language. However, I can't find any ruby libraries of gems. Specifically, I'm trying to get the Oauth keys for desktopcouch.
How can this be acheived?
...
i am screenscraping using watir and i download a xls file. when i open this file in notepad, i find that its just a bunch of html tables. is there a any function or gem that will convert this page into a bunch of arrays.
any ideas is appreciated.
...
Ok so i have an application that i use this jquery
$("#band_events").load("/load_events/"+ escape($('#request_artist').val()), successCallback );
It works great but if #request_artist is R.E.M. or somehthing with decimals or something weird rails has problems like
ActionController::RoutingError (No route matches "/load_events/R.E.M....
I have a venue model and i want to do this
Venue.find_or_create_by_
but i only want a new venue to be created if one with the same name and date do not already exist
For example
=> Venue(id: integer, location: string, showdate: datetime, created_at: datetime, updated_at: datetime)
A venue is unique and needs to be created if the l...