开发者

How do I configure a Rails app to use just Redis?

开发者 https://www.devze.com 2023-03-05 06:04 出处:网络
I want to use Resque in a Ruby on Rails application. I have no need for a relational database nor do I plan to store anything. I just want to use Resque.

I want to use Resque in a Ruby on Rails application. I have no need for a relational database nor do I plan to store anything. I just want to use Resque.

How do I configure this application?

I did this:

Empty config/database.yml

In config/application.rb

#require 'rails/all'
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"

And removed the < ActiveRecord::Base in my models.

But I get errors here:

class ProjectController < ApplicationController
  def index
    @project = Project.new
  end
end

=simple_form_for @project do |f|
    =f.input :开发者_运维知识库scene, :label => 'Scene'
    =f.submit

ActionView::Template::Error:
   undefined method `model_name' for Project:Class

How can I do this?


Make your model inherit from ActiveResource::Base instead:

class Project < ActiveResource::Base
  # ...
end

That will provide the methods required by helpers such as form_for without the need to use ActiveRecord.


If you don't need rails you don't need to use rails.

You can simply gem install resque and use a different web application framework.

I recommend looking at Sinatra, or Camping.

http://www.sinatrarb.com/intro

https://github.com/camping/camping

EDIT: Resque already comes with a full functioning Sinatra app that may suit your needs.


If you no need to use full Rails stack, use Sinatra. I like the Resque way to connect to Redis. I do not suggest you to use queues, just storage from here: Resque.redis.rpush

0

精彩评论

暂无评论...
验证码 换一张
取 消