Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Issues using gem #243

Closed
BeenaShetty opened this Issue Jun 28, 2013 · 13 comments

Comments

Projects
None yet
4 participants

I have installed shoes in Ubuntu through Ubuntu Software center. Basic shoes app was running properly but when i tried to use gems inside it , it throwed error
"Undefined method setup for Shoes:Class"

Code:

Shoes.setup do
gem 'activerecord' # install AR if not found

require 'active_record'
require 'fileutils'

ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:dbfile => 'shoes_app'
)

create the db if not found

unless File.exist?("shoes_app.sqlite3")
ActiveRecord::Schema.define do
create_table :notes do |t|
t.column :message, :string
end
end
end

end

class ShoesApp < Shoes
require 'note'

url '/', :index

def index
para 'Say something...'
flow do
@note = edit_line
button 'OK' do
Note.new(:message => @note.text).save
@note.text = ''
@result.replace get_notes
end
end
@Result = para get_notes
end

def get_notes
messages = []
notes = Note.find(:all, :select => 'message')
notes.each do |foo|
messages << foo.message
end
out = messages.join("n")
end

end

Shoes.app :title => 'Notes', :width => 260, :height => 350

Please suggest something

Owner

steveklabnik commented Jun 28, 2013

I don't know what version of Shoes you'd get through the Ubuntu Software Center, it is probably very old.

I suggest that you use Shoes 4 or Green Shoes instead. They will work much better.

thanks, I will try using shoes 4.

I have installed Shoes4. But still getting error as
"NoMethodError: undefined method `setup' for Shoes:Module"

Owner

PragTob commented Jun 28, 2013

Hi there, Shoes4 does not need the setup method as with Shoes4 you can just install gems from the command line like gem install gem_name. There is an issue open to implement it for compatibility reasons: shoes/shoes4#235 but it will not install the gem, just print a warning that you should not use that method anymore :-)

edit: I might tackle that issue soonish

Member

plexus commented Jun 28, 2013

Apparently Shoes has indeed been included and Debian and Ubuntu for a while
now, see

http://packages.debian.org/search?keywords=shoes&searchon=names&exact=1&suite=all&section=all
http://packages.ubuntu.com/search?keywords=shoes&searchon=names&exact=1&suite=all&section=all

The latest Ubuntu package has as its version "0.r396-5.3"

Can anyone tell off the bat how old that would be? I'm not sure how to
relate that with what I'm seeing in version.h/version.rb

On 28 June 2013 11:58, Tobias Pfeiffer notifications@github.com wrote:

Hi there, Shoes4 does not need the setup method as with Shoes4 you can
just install gems from the command line like gem install gem_name. There
is an issue open to implement it for compatibility reasons:
shoes/shoes4#235 shoes/shoes4#235 but it will
not install the gem, just print a warning that you should not use that
method anymore :-)


Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes/issues/243#issuecomment-20179765
.

When i try to inherit class from Shoes gets error as
"TypeError: superclass must be a Class (#Class:Shoes given)"

code:
class ShoesApp < Shoes
end

Member

plexus commented Jun 28, 2013

Sorry about that, some things have changed with the new version of Shoes.
The new syntax would be

class ShoesApp
include Shoes

end

in issue #263 we are discussing to maybe bring back the old syntax.

On 28 June 2013 12:16, BeenaShetty notifications@github.com wrote:

When i try to call inherit class from Shoes gets error as
"TypeError: superclass must be a Class (#Class:Shoes given)"

code:
class ShoesApp < Shoes
end


Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes/issues/243#issuecomment-20180583
.

Owner

PragTob commented Jun 28, 2013

The old syntax is almost certain to return :-) Sorry shoes4 is not quite ready yet, we are in pre-alpha at the moment but working hard for an alpha release :-)

Member

plexus commented Jun 28, 2013

Yes! So please keep posting any issues you have, we'll try to help. We can
really use the feedback, and from here on it will only get better :)

On 28 June 2013 12:52, Tobias Pfeiffer notifications@github.com wrote:

The old syntax is almost certain to return :-) Sorry shoes4 is not quite
ready yet, we are in pre-alpha at the moment but working hard for an alpha
release :-)


Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes/issues/243#issuecomment-20181952
.

I am trying to connect postgresql database using Activerecord gem.
Getting error
LoadError: Could not load 'active_record/connection_adapters/postgresql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.

code:

Shoes.app :title => 'Notes', :width => 260, :height => 350 do
require 'activerecord'
require 'fileutils'
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:host => 'localhost',
:database => 'shoes_app'
)

# create the db if not found
unless File.exist?("shoes_app.sqlite3")
    ActiveRecord::Schema.define do
        create_table :notes do |t|
            t.column :message, :string
        end
    end
end

end

Member

plexus commented Jun 28, 2013

Not really a Shoes problem but I'll try to help. I think because Shoes
uses JRuby you're supposed to use the JDBC adapters. Try this

gem install activerecord-jdbcpostgresql-adapter

As :adapter specify 'jdbcpostgresql'

This page has more info

https://github.com/jruby/jruby/wiki/RunningRailsWithActiveRecord-JDBC

This line however

unless File.exist?("shoes_app.sqlite3")

only makes sense if you're using sqlite3. It's trying to create your
database only if it doesn't exist yet, but shoes_app.sqlite3 will never get
created so it will do that every time, and the second time you'll probably
get an error.

The easiest solution would be to put that ActiveRecord::Schema.define block
in a separate script (include the 'require' and 'establish_connection' as
well) and just run it once before you start your app.

Hope that helps :)

On 28 June 2013 13:09, BeenaShetty notifications@github.com wrote:

I am trying to connect postgresql database using Activerecord gem.
Getting error
LoadError: Could not load
'active_record/connection_adapters/postgresql_adapter'. Make sure that the
adapter in config/database.yml is valid. If you use an adapter other than
'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem
to the Gemfile.

code:

Shoes.app :title => 'Notes', :width => 260, :height => 350 do
require 'activerecord'

require 'fileutils'
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:host => 'localhost',
:database => 'shoes_app'
)

create the db if not found

unless File.exist?("shoes_app.sqlite3")
ActiveRecord::Schema.define do
create_table :notes do |t|
t.column :message, :string
end
end
end

end

Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes/issues/243#issuecomment-20182554
.

thanks a lot. It worked

Owner

PragTob commented Jul 5, 2013

Ok great, then I'm closing this issue :-)

@PragTob PragTob closed this Jul 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment