lundi 25 janvier 2016

Accessing gem class methods in rails app

I have created my own gem 'mygem'. In the lib directory I have mygem.rb ruby file. This file has 3 methods defined.

Now I have created a rails app and I intend to use my gem in this app. In the controller ruby file I want to create a object and use the methods of my gem. But it is giving me error.

Here is the code of my controller ruby file:-

class StaticPagesController < ApplicationController

obj= Newgem.new()    

 def home

@message1= obj.head

 @message2= obj.paraone

 @message3= obj.paratwo

end
end

Aucun commentaire:

Enregistrer un commentaire