ceth
ceth

Reputation: 45285

require other modules in the controller

gem install rubyoverflow
irb
> require 'rubyoverflow'
=> true

But:

require 'rubyoverflow'
include Rubyoverflow

class QuestionsController < ApplicationController
    def question_by_tag
        ruby_q = Questions.retrieve_by_tag('ruby')

Get error:

LoadError in QuestionsController#question_by_tag no such file to load -- rubyoverflow

Rails.root: D:/artefacts/dev/projects/stack

app/controllers/questions_controller.rb:1:in `'

This error occurred while loading the following files: rubyoverflow

Is there any special rules to import moduled in the controller?

Upvotes: 0

Views: 3001

Answers (1)

fl00r
fl00r

Reputation: 83680

why do you use both require and include? include Rubyoverflow will be enough

UPD

For gem you should add it into your Gemfile (Rails 3.x) or config/environment.rb (Rails 2.x)

# Gemfile
gem "rubyoverflow"
# environment.rb
config.gem "rubyoverflow"

Then run bundle for Rails 3.x and rake gems:install for Rails 2.x

Upvotes: 2

Related Questions