ruby-on-rails

ActiveRecord::Base Without Table (rails)

This came up a bit ago (http://stackoverflow.com/questions/399490) but it looks like the Rails plugin mentioned is not maintained (http://agilewebdevelopment.com/plugins/activerecord_base_without_table). Is there no way to do this with ActiveRecord as is? If not, is there any way to get ActiveRecord validation rules without using Activ...

How can I send Javascript events back to Rails to process?

If I have user interactions in my Javascript layer, can I have Javascript actions trigger Rails controller actions and pass data from Javascript to those Rails methods? ...

I get this error when installing a gem: "ERROR: While executing gem ... (Zlib::GzipFile::Error)"

When installing a gem on my system, I get the following error: gem install blackbook --version ">= 1.0.7" --source http://github.com/tamoyal/blackbook/tree/master ERROR: While executing gem ... (Zlib::GzipFile::Error) not in gzip format Any ideas as to why this is happening? I built the gem so maybe it is something wrong with my...

Referencing controller methods in my index page in a scaffold-ed rails app

Hi, rails newbie here. I've started making a value based to-do list. So far I've scaffolded my app like this: dir> rails --database=mysql test1 dir> cd test1 test> ruby script/generate scaffold list item:string done:boolean value:int [Changed default value of done to false in the migration file] test> rake db:migrate All is working ...

How to unobtrusively update the page title with JS (in Rails)

Whenever I load a blog post onto the page with Ajax, I set the page <title> to "My Blog - BLOGPOST_TITLE". Of course "My Blog - " appears in my application layout as well. The question is, how do I tell my Javascript about the string "My Blog - " without duplicating it in my code? ...

Upgraded mysql from 5.0 to 5.1, now Rails 2.3 is broken (on Mac)

I upgraded mysql on my Mac from 5.0.x to 5.1.x (using a dmg package directly from mysql.com), which broke Rails (2.3.2). Previously everything was working correctly. The error I get is this: !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. So I tried re-inst...

how to map non-standard table with ActiveRecord or should I use other ORM?

Hello, I'm using a tool(UltraSms) that required three tables named (smsin, smsout & smsparts) I need these tables to be used in the same Rails application that has other tables. With ActiveRecrod I know that table names has to be plural of the Active record class name by convention. Is there a way to map those to an ActiveRecrod class...

Writing Rails app with SQL first

Say for example I've got an SQL schema that is ready to go. How would I import it into my Rails app so that I use my prepared database instead of all those funny migrations. EDIT: You have all misunderstood my question so far. I'm asking if I had a working database application in say PostgresQL. How would I use this as the basis of my R...

Problem with custom routes in Rails

I have this line in routes: map.resources :questions, :new => {:vote_for => :put, :vote_against => :put}, :has_many => :replies, :shallow => true And I use the following helpers in my view: link_to 'OK', vote_for_question_path(@question), :method => :put link_to 'NO', vote_against_question_path(@question), :method => :put But unfort...

Wiki-like formatting in Rails

I forgotten the name of this library. But it's sort of like Wiki how you type certain characters in front of your text, and then it'll make the text bold/italic/underline. I'm not asking for the way Wiki is formatted but I'm aware there is something similar built into Rails. It's at the tip of my tongue. Thanks. ...

How can I find non ascii strings in an array of strings, in Rails 2.0/ruby 1.8.6?

I have an array full of user logins that was loaded from the database. What's the simplest and efficient way to keep only the logins that contain non-ascii characters? logins = Users.find(:all).map{|user|user.login} logins_with_non_ascii_characters = logins.select{ |login| ...??? } Thanks Edit: if you have a SQL solution (I use MySQ...

Does Rails' Ajax support make JSON or XML an easier format to work with?

Being new to Ajax, I would like to understand which data exchange format - JSON or XML - would be easier to work with while doing Ajax in Rails. Do the various Rails helpers make one or the other format easier to deal with or does it depend on the context or does it not matter at all? ...

How do I get the Rails test database to rebuild before each test?

I'm currently in the process of beginning a migration from fixtures to factories and running into some test database challenges. When I run my entire test suite the database is cleaned out and the new factory-generated data reloaded. However, when I run individual unit tests the database does not clean out the old values. I could run ...

Pattern for unidirectional has_many join?

It occurred to me that if I have a has_many join, where the foreign model does not have a belongs_to, and so the join is one way, then I don't actually need a foreign key. We could have a column, category_ids, which stores a marshaled Array of IDs which we can pass to find. So here is an untested example: class page < AR def categ...

How do you create a configurable Ruby on Rails plugin?

i am trying to create my first rails plugin, and i want it to be configurable, that is to say, i want to be able to set a variable in the environment.rb file or something. UPDATE: i'm trying to do something like what's done here: http://soakedandsoaped.com/articles/read/exception-notifier-ruby-on-rails-plugin. i have tried mimicking th...

What would cause Rails page caching to stop working?

I've got a Rails app that has stopped caching somewhere along the way, and I'm not sure which revision along the way might have stopped it from working. I'm under the impression that page caching, when working properly, should never even hit Rails if it finds the cached file. However, when loading my page and monitoring production.log, ...

Understand Rails Authenticity Token!

I am running into some issues regarding Authenticity Token in rails, as I did many times now. But I really don't want to just solve this problem and go on, I would really like to understand Authenticity token. Well, my question is, do you have some complete source of information on this subject or would spend your time to explain in deta...

Share rails sessions among applications.

I have two applications and want them to share their sessions. This is trivial, at least so far. Now I am running in some stange issue. I have set the same session_key and secret in the environment.rb and the two applications did not share the same session. Verified if development.rb has something... nothing. Tried to cleanup cookies ...

Which gems can a Rails app survive without?

actionmailer actionpack activeresource activesupport I have a basic scaffolded CRUD app that uses ActiveRecord to connect to a SQLite database and I have frozen my Rails gems. Which of these gems could I delete without affecting my app? ...

How do I change the format dropdown box of the TinyMCE ruby plugin?

I'd like to only allow h2 and h3, but I'm not sure how to edit the list in the dropdown shown by adding the 'formatselect' button. ...