ruby-on-rails

How do I find a specific entry inside a zipped directory using the rubyzip gem?

I have a zip file named test.zip which contains a directory named invoice. Inside the invoice directory there are documents each with different names. I would like to find a specific document named summary.txt which is inside the invoice directory. I am able to get a handle to test.zip using the following: zip = Zip::ZipFile.open("/p...

Rails is continually running in test mode

After upgrading to rails 2.3.5 I got things working again and the tests were passing. Then all of a sudden when I run the script/server command it now always runs in Test mode which is seen by a simple > puts RAILS_ENV I have restarted my machine as well as run the script/server command manually setting the environment via -e, but stil...

Passing @object into a rails partial render

I have a partial: 'profiles/_show.html.erb' that contains code like <%= @profile.fullname %> I'm trying to render the partial but I'm not sure how to pass the @profile. I tried using local but apparently it sets 'profile' on my partial instead of '@profile'. <%= render :partial => 'profiles/show', :locals => {:profile => @app.profi...

Rails Community Engine plugin unit tests fail

Community Engine installed fine locally on my mac, but when I try to install it on my web server, it's giving me some trouble. Here's the problem I'm having now, when I run rake test $ [~/projects/polis]# rake test --trace (in /home/mculp/projects/polis) ** Invoke test (first_time) ** Execute test ** Invoke test:units (first_time) ** In...

Forms being submitted as get requests

With the upgrade to rails 2.3.5 suddenly ALL my forms are now submitting via GET requests. I upgraded from rails 2.0.x, so is there something that I missed out on along the way? Is anyone else seeing this? Example - Login form <form action="/submit_login" method="post"> <table class='form'> <tr> <th> ...

Rails is not recognizing an installed gem

I tried to install the ruby-hmac gem If I do "gem list", I see it is installed: ... RedCloth (3.0.4) ruby-hmac (0.3.2) ruby-openid (1.1.4) ... However when I try to include it in my Rails project... config.gem "ruby-hmac" I get an error: Missing these required gems: ruby-hmac You're running: ruby 1.8.6.287 at /System/Libra...

How do you actually see the html output during a functional test in rails

One of my assert_selects is driving me up the wall. Its failing and of course its telling me what it expected but Id like to see what was actually there on that page when it rendered to track down this bug. Ive already tried using my browser and the app is behaving as it should but thats using development data. Is there a command i c...

How rails issue put method on update ?

On edit.html.erb file, scaffold created, I don't see any code specified PUT method. How come the post form call update action with PUT method. ...

Display conditional values in a Formtastic select

How do I instruct Formtastic select to only display values based on a condition? - semantic_form_for @member do |f| - f.inputs do = f.input :person = f.input :role, :include_blank => false = f.input :active I only want the :person input to list/select people who are active i.e. person.active == true. I tried to pass a co...

How to have pdf viewer in ruby

How can I embeded pdf viewer in ruby on rail? Now I tried <embed src="MyPdfDocument.pdf" width="500" height="375"> but it doesn't work. I used firebug and see the error like this [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIStreamListener.onStopRequest]" nsresult: "0x80004005 (NS_ERROR_FAILURE)"...

Tricky data conversion excercise

I have weather history data which I need to plot on a web page using (highly recommended) jquery flot. The app behind is in RoR. One of the data series describes overall weather state for a date such as 'heavy showers', 'light snow', etc. Now flot expects decimals in data input. Flot also allows to reformat data when it comes down to s...

Can Ruby 1.9 used with Rails by a Ruby/Rails beginner?

About half a year ago, when I started to learn Ruby and Rails, I first tried Ruby 1.9 but I soon gave up, because at that time nothing worked out of the box and almost every helping blog or tutorial was designed for Ruby 1.8. What about now? (Dec 2009) Is it possible to get an existing Rails application running by a Ruby and Rails begin...

Trying to start backburner server for Rails application and failed

I've just created a new rails application using command: rails blog Now I'm following blog/README file. To get started, I'm trying to start backburner server as stated in the README file: Change directory into myapp and start the web server: script/server (run with --help for options) Using the server command I started backburner ...

Best way to output a tag who's name is dynamically created?

In my Rails application I have a partial which is called recursively. In the partial I want to output a <h1>, <h2>, <h3> ... depending on the level. (Cap at level 6, of course) Something like this: <h1> <p><%= ... %></p> <% books.each do |book| %> ... <% end %> </h1> -------> <% open_h(1) %> <p><%= ... %></p> <% books...

Is calling a partial an expensive operation?

Can I use partials as much as I want or do I have to restrain myself to avoid bringing my views to a crawl under much traffic? ...

How's the latest Ruby on Rails code?

So I've been programming in PHP for the past 7 yrs. What I should be doing is learning OOP but all the talks about RoR and Django interest me even more. With that said, I started to follow RoR when it first came out. I knew of it through 37signals when I was first introduced to their products. At the time, I continued to use PHP, it was ...

Rails returns a 500-error (Not sure why)

I've been trying to get Rails working, but whenever I try to create my own view, it returns a 500 error. So, here's the steps I've followed to get where I am: I installed Ruby to C:\Ruby I installed Rubygems to C:\Ruby\rubygems-1.3.5 and ran ruby setup.rb In the cmd prompt, I installed rails using gem install rails. I created a Project...

What is the proper way to handle "types" in Rails?

Hi, sorry if this question has been asked before, I searched but wasn't sure on the proper name for what I'm looking for. I'm pretty much a newcomer to rails and development in general, I've done some hacky programming but I wouldn't say I know what I'm doing. I've always been at a loss on how to define "types" in my Rails models and in...

Migrating from Drupal to Rails - Routing

I've developed a new Ruby on Rails site for my organization. I want the new Rails site to intercept incoming requests that were meant for the old site and display a message for the user indicating that the new site is launched, a link the new URL they were most likely trying to get to, and a reminder to update bookmarks. So I'm prett...

Where to put custom JavaScript/Prototype code for an ActiveScaffold form?

I have a Select dropdown on the form of an ActiveScaffold. I am trying to hide some of the fields on the form if a particular value is selected. A [similar question][1] was posted to the ActiveScaffold Google Group, and the supplied Prototype code looks to do what I need, however I don't know where I need to add this. -- I tried taki...