Ruby on Rails: How do I move all files from one folder to another folder?
But I also need a way to rename them incase there are conflicts. Like if exists? then file.name = "1-"+file.name or something like that ...
But I also need a way to rename them incase there are conflicts. Like if exists? then file.name = "1-"+file.name or something like that ...
What the current stable recommended release of Ruby? 1.8.7 or 1.9.x? I will be deploying a rails(v 2.3.8) app & was wondering what version of ruby should I be using. My deployment environment is Ubuntu/Apache/passenger (mod_rails) RubyOnRails.org website says - "We recommend Ruby 1.8.7 for use with Rails" I want to know - whats the re...
I have file_ext = attach.document_file_name.capture(/\.[^.]*$/) but i guess there is no method capture. I'm trying to get the file extension from a string. I don't yet have the file. ...
Hello, I have a quick parsing question. I have a file with the following structure <admin> <sampleName>Willow oak leaf</sampleName> <sampleDescription comment="Total genes"> <cvParam cvLabel="Bob" accession="123" name="Oak" /> </sampleDescription> </admin> I'm trying to get out the text "Total genes" after the sampleDes...
I've been updating my user test server and now suddenly I got an error every time I invoke rake with anything database-related. Sample error: rake db:drop RAILS_ENV='production' --trace rake aborted! undefined method `[]' for false:FalseClass /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:96 Here's line 96 of...
I started learning Ruby on Rails and found myself confounded by the syntax, so I had to read about somet of the Ruby syntax. I learned the syntax from http://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Manual/man-1.4/syntax.html: method_call do [`|' expr...`|'] expr...end They call it an Iterator. I understand an iterator runs th...
I have this line.. @organization.search_image = File.open(@photo.photo.path(:original)) Except that 's looking for something local, and all my photos are on S3 now. How would I translate that to opening a file on S3? ...
Hi All, I've encountered the following error while trying to create a blogging application. Any ideas why? NoMethodError in Articles#show Showing app/views/articles/show.html.erb where line #1 raised: undefined method `title' for []:Array Extracted source (around line #1): 1: <h2><%= @article.title %></h2> 2: 3: <% if @article...
I am trying to use acts_as_taggable plugin to include tag functionality in my ruby on rails application. I have attached the code. I have installed the plugin and also run the migrations.I am getting the following error. undefined method `each' for "value of the parameter":String Code location.rb - location table has name, tags(this ...
I just had a quick question regarding loops in Ruby. Is there a difference between these two ways of iterating through a collection? # way 1 @collection.each do |item| # do whatever end # way 2 for item in @collection # do whatever end Just wondering if these are exactly the same or if maybe there's a subtle difference (possibly ...
I am creating an application where I want to add metadata about table fields from an enterprise system. I have a table_structure model which retrieves a table definition information like: table_name field_name Field_type field_length ... a particular field may exist in multiple tables like: tableA fieldX tableB fieldX regardless ...
I'm writing a Rails application which need to maintain a session to a SOAP-based web service, but I'm running in to difficulties between SOAP/REST. After logging in I get a session token, which must be provided in subsequent requests. I can initiate a connection (including logout) every time, but it seems like a huge amount of overhead...
My app takes a loooong list of urls, and split it in X (where X = $threads) so then I can start a thread.php and calculate the urls for it. Then it does GET and POST request to retrieve data I am using this: for($x=1;$x<=$threads;$x++){ $pid[] = exec("/path/bin/php thread.php <options> > /dev/null & echo \$!"); } For "threading"...
I'm writing a rack middleware component for a rails app that will need to conditionally set cookies. I am currently trying to figure out to set cookies. From googling around it seems like this should work: class RackApp def initialize(app) @app = app end def call(env) @status, @headers, @response = @app.call(env) @r...
I want to return a list/collection of all numbers in a range that are a multiple of 3 or 5. In Ruby, I would do (1..1000).select {|e| e % 3 == 0 || e % 5 == 0} In Clojure, I'm thinking I might do something like... (select (mod 5 ...x?) (range 0 1000)) ...
I have the following code. I want to use the methods for myserver1 and myserver2 and pass them the addresses the have been iterated through in the send_to_servers method. I can't seem to do that. Please help. Unless I can have these two receive addresses on an altering basis, I won't be able to do what I need to do. Thanks in advance. c...
I have installed Munin to provide some insight into server performance for a VPS server with some small rails and Sinatra applications. Is there a good resource for reading up on what to look for on the graphs Munin provides. Or a good resource on getting more details on specific measures (Fork rate, Swap in/out) - what they are tellin...
I'd like to iterate Outlook Inbox and I'm with Ruby. I've found some useful info here, but the order of message in Inbox is not ordered by RecevedTime(Property for Item OLE object). GetLast method may find the latest message but GetPrevious method does not work as I expected. require 'win32ole' outlook = WIN32OLE.new('Outlook.Applicat...
Possible Duplicate: Why does array.slice behave differently for (length, n) In Ruby koan "about_arrays.rb", test_accessing_array_elements there's two similar start/length slice statements accessing parts of an array. Ref extract below. Both should be "out of range" yet one returns an empty array and the other returns nil. This...
I'm using net-ssh to iterate over a couple of hosts in a loop. This bit of code will throw an error if the username entered is incorrect. Net::SSH.start(host, user) do |ssh| out = ssh.exec!(exec) puts out ...