ruby-on-rails

Integrating PHP/General HTTP Request with Rails

I have a Rudy on Rails backend which I use because it has some libraries that other languages don't have. I'm trying to use it as a web service/backend and accept requests from PHP/general HTTP request pages. It should be very simple - hopefully, accept a JSON object and respond with a JSON object. Rails seems to default to a RJS/ non-st...

Why is the id# returned rather than the value of the id?

cart.rb: def vendor3name @items.first { |item| item.vender.name } end When I call the method, I'm looking for the vendor name but it returns the vendor ID#. What am I doing wrong? <%= @cart.vendor3name %> CartItem:0x264c358 ...

Rails STI using ONE form

I have a form that allows me to add files of different formats to a stream. So, a stream is made up of many files, these files are XML files but basically have different schemas. I have one form that allows the user to add whatever file they want, I am using STI (which works great when data is already in the table), my trouble is adding ...

Clearing a Rails Session during Development

How do I clear the rails session so I can start with a fresh slate? I know I could just nullify each of the session variables with session[:my_var] = nil, but is there a rake task or something that knows how to restore the session data to its most basic form? I'm using Spree and it stores a few properties in the session that I would li...

Acts_as_list descending instead of ASC numbering

I'm using acts_as_list plugin to sort my to do lists. * [drag] Test 1 * [drag] sadf 2 * [drag] asdf 3 However I want the numbering to the DESC instead. So it shows as * [drag] Test 3 * [drag] sadf 2 * [drag] asdf 1 How do I do that? Thanks ...

Implementing chat system with in Web browser

We want to have web based application to track the issues, knowledge management and chat system. Once the user logged in, user can chat with the service engineers. We will be using Ajax for Chat within the browser. But the server-side we are not sure how to implement chat? The chat history must be saved for lateral viewing. When someone...

Is it possible to search for dates as strings in a database-agnostic way?

I have a Ruby on Rails application with a PostgreSQL database; several tables have created_at and updated_at timestamp attributes. When displayed, those dates are formatted in the user's locale; for example, the timestamp 2009-10-15 16:30:00.435 becomes the string 15.10.2009 - 16:30 (the date format for this example being dd.mm.yyyy - hh...

What makes an effective URL Mapping implementation and why?

I am looking at implementing URLMapping for a personal project. I am already aware that solutions exist so please do not answer suggesting I should use one. What I want is to harvest the opinions of fellow developers and web users on URL mapping implementations. Specially I would like you to answer: Which is your favourite implementa...

accepts_nested_attributes only accepts attribute per model?

I've a model which has to accept two nested attributes, however I get the error undefined methodquoted_table_name' for ActiveRecord::Error:Class` Can a model only have one accepts nested attributes? I'm using build method in controller btw to pass nested attributes. ...

How are Ruby and Rails related?

First of all, i want some clarification :) 1) Is RoR like a server scripting language? 2) Can it be used as an alternative to php? I started learning Ruby from The Ruby Programming Language book and haven't yet come across something which relates to the web. Is Ruby for desktop apps and Rails for web apps? Thanks ...

Jquery Facebox plugin doesn't work

I downloaded facebox from famspam.com/facebox. Then I added facebox.js to be in public/javascripts folder, and facebox.css in public/stylesheets Then I included this files in my application.html.erb AFTER original Jquery library ver 1.4 The last, I set a rel attribute to my a href tags to try to use Facebox, but it doesn't appear. When...

Rails with Oracle often got "no listener" error

I am on Rails 2.3.5 and use oracle 10 as my database,use oracle_adapter ,ruby-oci8 to connect oracle host. But I often got exception as the log info show: Completed in 463ms (View: 18, DB: 166) | 200 OK [http://192.168.30.128/auctions?page=1] /!\ FAILSAFE /!\ Mon Feb 01 19:02:11 +0800 2010 Status: 500 Internal Server Error ORA-12...

How do I generate XML from XMLBuilder using a .xml.builder file?

I have started using xml builder templates for most of my model. I need to find a generic way to build XML outside of a render which uses the .xml.builder template instead of the generic .to_xml method provided in the model I gather that I will have to override the default to_xml (or add a to_my_xml), but I am unable to see how to get X...

how to integrate a flex application into a rails environment

Hi everybody, I have a webpage based on ruby on rails. For one task I need some more complex user interface which I plan to do with a flex programm. The question is, how I can start the a new window with my flex programm and hand over the right url where the flex app can load its data in XML format... Thanks in advance Markus ...

Rails geokit caching

How would you cache GeoKit requests? This does not work for me... Geokit::Geocoders::query_cache = true Geokit::Geocoders::query_cache_max_age = 86400 # 1 day in seconds URL: http://github.com/seebq/geokit-gem ...

Rails save object to cookie

How can I serialize an array or an object and then save it into a cookie? cookies[:mydata] = serialize({ :key1 => 'tralala', :key2 => 'hahaha' }) Thx! ...

Display if attribute is same as today's date

So I am working on an application where I want to display a video on the main page of the site. The video model has an actual_date and public_filename attribute. Now a user sets the actual date as :date in the model. I am trying to figure out how to best go about making the video on the homepage display the video that is assigned to toda...

Email Users Each Day Based on Attributes

This is more of a macro type question, I am looking for plugin/how to go about advice. I have users who have different subscription attributes, some might have monday, wednesday, saturday... some might have every day of the week. I need to set up a mailer that will send out a specific template at 5:00am every day to every user that has a...

Rails 3 / Bundler gem: 'undefined method `setup' for Bundler:Module (NoMethodError)'

It can be traced back to config/boot.rb, line 7: require 'rubygems' require 'bundler' Bundler.setup This is with Bundler 0.8.1 supposedly installed: ../Users/ashley$ sudo gem install bundler Successfully installed bundler-0.8.1 1 gem installed Installing ri documentation for bundler-0.8.1... Installing RDoc documentation for bundler-...

Rails ENV variable inside Module

How can I read ENV variable module MyModule def self.current_ip request.env['REMOTE_ADDR'] end end MyModule::current_ip How to? ...