ruby

Trouble with Ruby on Rails with Rake

Hello Everybody, I'm very new to Rails, so please forgive my lack of understanding. I've installed the latest versions of RubyGems, Ruby, Rails, Rake, and MySQL etc via RubyGems, but I have this problem when starting to make a basic Rails app: Icarus:temporary atg$ rails new people ... (output omitted) ... Icarus:temporary atg$ cd ...

Should I create two different sets of 'category' models? Ruby on Rails.

Hello, I have two models on the Rails app that I am working on, Article and Profile. I want them to have separate sets of categories. Should I create two different category models? article_category and profile_category? There will be lots of redundant code if I do this. ...

how to collect particular type of data with ruby scripting

I have 5 files file1.txt file2.txt....file5.txt then I have list of 3 words red white blue I am trying to find out how many times and in what files red white blue occur. Finally the format should be: red = file1.txt, file3.txt, 2 white = file2.txt, 1 blue = file1.txt, file2.txt, file3.txt, 3 This is what I have so far: files.each ...

Uses of Ruby on Rails

I am a somewhat experienced rubyist, but I am now starting to do rails development. I know rails is used to make "web applications" but what exactly does that mean? Do you build entire sites with rails or do you build a feature for a website in rails, and integrate it in to an existing website? (I know this question is kind of vague, but...

Ruby gem mysql2 install error

I have the Ruby version ruby 1.9.2p0 (2010-08-18) [i386-mingw32] installed in Windows7. and the gem vesion 1.3.7 When i tried to install mysql gem, it is showing Failed to build gem native extension error, why is this? my mysql version is 5.1.36(WampServer) E:\RubyApps\test_app2>gem install mysql2 Building native extensions. This cou...

422 "" Net ::HttpServer Exception error in ruby for calling API

Hi , i am new to Ruby on rails I am writing code for calling Api code .. I have written a post request ruby code for testing my Api blogs.. require 'net/http' require 'uri' url = URI.parse('http://localhost:3000/api/blogs/create.xml') req = Net::HTTP::Post.new(url.path) req.basic_auth 'a', 'a' req.set_form_data({'blogpost[...

Is it possible to uninstall ruby gems, rails etc and do a complete clean install?

I seem to be having issues with gems and want to start with a fresh install. Is this possible without reinstalling Snow Leopard from scratch? Thanks in advance, Galen ...

if __FILE__ == $0 problem with main.

Hi, Im currently working on a project for my first course in Ruby. A part of the assignment is to have a main class as the one below. I have it in a separate file and the other modules and classes are in separate files. Now Im getting an uninitialized constant Main::Camping (NameError) which I dont get. Any clues to why?! Thanks Regards...

Rails 3: @template variable inside controllers is nil

Hello guys! I have the same problem, as in this question. Did anybody find any solutions for this? So I can't do like this: flash[:notice] = "Successfully created #{@template.link_to('product', @product)}. or like this: @template.title("Page title is here.") It worked perfectly in Rails 2.3. The main idea is to find out, how to u...

Why is Ruby 1.9.2 on Windows 7 using a 1.9.1 path for gems? it is using c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb

I installed Ruby 1.9.2 using one click installer to c:\ruby192 It doesn't set any path, so I set it to include c:\ruby192 at the very beginning of the path. But when it error on something (for Rails 3.0), the path says: [Error message] c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb why is it 1.9.1 gems path...

Some Ruby code runs well in script/console but not with script/runner, why?

I am actually using Rails 3.0, so it is rails console vs rails runner try.rb. The following code runs well in the console but not as a script with runner. I need runner (instead of using ruby try.rb) because there are some ActiveRecord code for the project. Update: I couldn't run it inside of myproj\lib\tasks\ (when the current direct...

Ruby Office Automation - cannot get event handlers to work in MSWord

Ruby version 1.9.1p430 running on W7 with Office 2010. I am trying to catch the DocumentBeforeClose event but I cannot even get close to get it to work! I have followed some examples using Excel where the SheetSelectionChange is handled. It works without any problem. Using the same process, I wanted to handle the above Word event. My...

Ruby on Rails, How to make a controller render different page without redirect?

Hello, Let's say we have the following pages clip/show/111 image/show/222 sound/show/333 where 111,222 and 333 are the IDs for different contributions I developed a new controller called "show" that will detect ID and redirect to the right controller show/show/111 will redirect to clip/show/111 and so on what I want is to render the p...

Rails and Rake commands hang and do nothing at all

I don't know why but when I run rake commands in my rails project, nothing happens. Also rails server does nothing. Any suggestions? ...

Net::HTTP::Put.new(url.path) shows the 401 error in RUby

HI , i am new to ROR i am writing Ruby code for calling API blogs i have written ruby code for Creating the blog by require 'net/http' require 'uri' url = URI.parse('http://localhost:3000/api/blogs/create.xml') req = Net::HTTP::Post.new(url.path) req.basic_auth 'a', 'a' req.set_form_data({'blogpost[title]'=>'TestingAPIBlogposttitle...

Search ruby hash for empty value

I have a ruby hash like this h = {"a" => "1", "b" => "", "c" => "2"} Now I have a ruby function which evaluates this hash and returns true if it finds a key with an empty value. I have the following function which always returns true even if all keys in the hash are not empty def hash_has_blank(hsh) hsh.each do |k,v| if v....

Architecture mismatch between a ruby gem and ruby?

I successfully installed the yajl-ruby rubygem via gem install, yet attempting to use it throws this error: /usr/local/lib/ruby/gems/1.8/gems/yajl-ruby-0.7.7/lib/yajl_ext.bundle: dlopen(/usr/local/lib/ruby/gems/1.8/gems/yajl-ruby-0.7.7/lib/yajl_ext.bundle, 9): no suitable image found. Did find: (LoadError) /usr/local/lib/ruby/gems/1.8/...

save two models from on form does not work ruby radrails

Hi, I'm a newbie with rad rails. I wanted to write at same time in two table from one form. I have a table machine (with nom and role as column) and a table ipvfour (with machine_id and ip as column). So I created in models the relation has-and-belongs-to-many. But when I'm trying to add a new machine if failed with unknown attribut...

ruby daemons - running but not functioning

hi, I have created my first ruby daemon and it functions fine for about a day but then it stops functioning but it still appears in the /var/run folder. here is my control code - require 'rubygems' require 'daemons' dir = File.dirname(__FILE__) options = { :app_name => "rk_mail", :dir_mode => :system, :backtrace => true, :log_ou...

rails multiple form actions with ajax...

I have a basic Rails form like so: <%= form_for @person do |f| %> <%= f.label :first_name %>: <%= f.text_field :first_name %><br /> <%= f.label :last_name %>: <%= f.text_field :last_name %><br /> <%= f.submit %> <% end %> How could I optionally send the form information to another an entirely different controll...