kurenn / sabisu-rails

Simple and powerful engine for exploring your Rails api application
MIT License
127 stars 29 forks source link

NoMethodError (undefined method `singularize' for :users:Symbol) #22

Closed veetase closed 9 years ago

veetase commented 9 years ago

Using rails 4.2 & ruby 2.2 & mongoid 4.0.1, when open the link: http://localhost:3000/sabisu_rails/explorer, error ocurrs, error detail is as blow:

NoMethodError (undefined method `singularize' for :users:Symbol):
  sabisu_rails (0.0.2.pre.beta) lib/sabisu_rails/explorer.rb:21:in `resource_name'
  sabisu_rails (0.0.2.pre.beta) app/controllers/sabisu_rails/explorer_controller.rb:7:in `index'

regard for your reponse.

courtenay commented 9 years ago

Make sure you have entries in config.resources and config.default_resource

kurenn commented 9 years ago

An example for how a super simple configuration may look is under a wiki article https://github.com/IcaliaLabs/sabisu-rails/wiki/How-to-configure-Sabisu-for-Heroku

Em01 commented 9 years ago

Did you resolve this? I also have the same error and i definitely have entries in config.resources and config.default_resource

kurenn commented 9 years ago

It is already merged! Thanks for the contribution @infused

levi-l-damian commented 9 years ago

Same error, I have the entries recommended, don't know how to fix it.

kurenn commented 9 years ago

@levi-l-damian Have you tried updating the gem via the github repo?

gem 'sabisu_rails', github: 'IcaliaLabs/sabisu-rails'
levi-l-damian commented 9 years ago

Yes, an bundle install failed to install the gem. The only line in my Gemfile that worked for me is: gem 'sabisu_rails' After I deleted the github reference, the bundle install succeeded and I got the gem installed.

On Mon, Apr 20, 2015 at 12:44 PM, Abraham notifications@github.com wrote:

@levi-l-damian https://github.com/levi-l-damian Have you tried updating the gem via the github repo?

gem 'sabisu_rails', github: 'IcaliaLabs/sabisu-rails'

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94504823 .

Levi

infused commented 9 years ago

You can work around this issue temporarily by setting default_resource to a string instead of a symbol:

config.default_resource = 'users'
levi-l-damian commented 9 years ago

Here are my lines as suggested:

Resources on the api

config.resources = [:users]

Default resource

config.default_resource = 'users'

Sorry, same error: RuntimeError in SabisuRails::Explorer#index

        raise("No input found for #{input_type}")

On Mon, Apr 20, 2015 at 1:13 PM, Keith Morrison notifications@github.com wrote:

You can work around this issue temporarily by setting default_resource to a string instead of a symbol:

config.default_resource = 'users'

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94512544 .

Levi

kurenn commented 9 years ago

Have you tried @infused solution?

levi-l-damian commented 9 years ago

No and don't know how?

On Mon, Apr 20, 2015 at 2:41 PM, Abraham notifications@github.com wrote:

Have you tried @infused https://github.com/infused solution?

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94534706 .

Levi

levi-l-damian commented 9 years ago

Not sure if these are relevant but these are my settings:

$ ruby -v

ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]

$ rails -v

Rails 4.2.1

On Mon, Apr 20, 2015 at 2:50 PM, Levi Damian levi.l.damian@gmail.com wrote:

No and don't know how?

On Mon, Apr 20, 2015 at 2:41 PM, Abraham notifications@github.com wrote:

Have you tried @infused https://github.com/infused solution?

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94534706 .

Levi

Levi

kurenn commented 9 years ago

Everything looks good with your stack.

And under config/initializers/sabisu_rails.rb you can set the configuration for Sabisu to look something like this:

SabisuRails.setup do |config|
.
.
.
 # Resources on the api
  config.resources = ['users']
  # Default resource
  config.default_resource = 'users'
end
levi-l-damian commented 9 years ago

OK, I applied your changes and I restarted the rails server: absolutely no difference, same error.

Here is my entire config file:

Use this module to configure the sabisu available options

SabisuRails.setup do |config|

Base uri for posting the

config.base_api_uri = 'api.marketplaceapi.dev'

Ignored attributes for building the forms

config.ignored_attributes = %w{ created_at updated_at id }

HTTP methods

config.http_methods = %w{ GET POST PUT DELETE PATCH }

Headers to include on each request

#

You can configure the api headers fairly easy by just adding the

correct headers

config.api_headers = { "Accept" =>

"application/json,application/vnd.application.v1" } # config.api_headers = { "Accept" => "application/vnd.marketplace.v1" }

Layout configuration

config.layout = "sabisu"

Resources on the api

config.resources = ['users']

Default resource

config.default_resource = 'users'

Application name

mattr_accessor :app_name

@@app_name = Rails.application.class.parent_name

Authentication

mattr_accessor :authentication_username

@@authentication_username = "admin"

mattr_accessor :authentication_password

@@authentication_password = "sekret"

end

On Mon, Apr 20, 2015 at 3:34 PM, Abraham notifications@github.com wrote:

Everything looks good with your stack.

And under config/initializers/sabisu_rails.rb you can set the configuration for Sabisu to look something like this:

SabisuRails.setup do |config| . . .

Resources on the api

config.resources = ['users']

Default resource

config.default_resource = 'users'end

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94548627 .

Levi

kurenn commented 9 years ago

It is maybe related to simple form, you can check out this discussion on the problem https://github.com/IcaliaLabs/sabisu-rails/issues/20

levi-l-damian commented 9 years ago

I had this error #20 before due to the fact that the sabisu gem wasn't installed. After installation succeeded I am not at "level" #22.

On Mon, Apr 20, 2015 at 3:44 PM, Abraham notifications@github.com wrote:

It is maybe related to simple form, you can check out this discussion on the problem #20 https://github.com/IcaliaLabs/sabisu-rails/issues/20

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94551051 .

Levi

levi-l-damian commented 9 years ago

.. I am now at level #22

On Mon, Apr 20, 2015 at 3:50 PM, Levi Damian levi.l.damian@gmail.com wrote:

I had this error #20 before due to the fact that the sabisu gem wasn't installed. After installation succeeded I am not at "level" #22.

On Mon, Apr 20, 2015 at 3:44 PM, Abraham notifications@github.com wrote:

It is maybe related to simple form, you can check out this discussion on the problem #20 https://github.com/IcaliaLabs/sabisu-rails/issues/20

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94551051 .

Levi

Levi

levi-l-damian commented 9 years ago

I am trying to learn from http://apionrails.icalialabs.com/book/ I am at the end of chapter 3. Here is my git repo (public), one single branch (master): https://github.com/levi-l-damian/market_place_api

Hope this helps.

On Mon, Apr 20, 2015 at 3:51 PM, Levi Damian levi.l.damian@gmail.com wrote:

.. I am now at level #22

On Mon, Apr 20, 2015 at 3:50 PM, Levi Damian levi.l.damian@gmail.com wrote:

I had this error #20 before due to the fact that the sabisu gem wasn't installed. After installation succeeded I am not at "level" #22.

On Mon, Apr 20, 2015 at 3:44 PM, Abraham notifications@github.com wrote:

It is maybe related to simple form, you can check out this discussion on the problem #20 https://github.com/IcaliaLabs/sabisu-rails/issues/20

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94551051 .

Levi

Levi

Levi

kurenn commented 9 years ago

@levi-l-damian I'm the author of that book! =) I'll take a look at your repo and try lo help! Thanks for reading btw!

levi-l-damian commented 9 years ago

Many thanks for help. I will have to build some API soon for an app or two and I wanted to learn first the best practises. I really enjoy reading your book. It is very well written, at least for people like me having some background in RoR, but not being an expert.

On Mon, Apr 20, 2015 at 4:00 PM, Abraham notifications@github.com wrote:

@levi-l-damian https://github.com/levi-l-damian I'm the author of that book! =) I'll take a look at your repo and try lo help! Thanks for reading btw!

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94554049 .

Levi

kurenn commented 9 years ago

I managed to solve it!

Here is step by step:

1

Change the sabisu_rails.rb initializer:

# Use this module to configure the sabisu available options

SabisuRails.setup do |config|

  # Base uri for posting the
  config.base_api_uri = 'api.marketplaceapi.dev'

  # Ignored attributes for building the forms
  # config.ignored_attributes = %w{ created_at updated_at id }

  # HTTP methods
  # config.http_methods = %w{ GET POST PUT DELETE PATCH }

  # Headers to include on each request
  #
  # You can configure the api headers fairly easy by just adding the correct headers
  # config.api_headers = { "Accept" => "application/json,application/vnd.application.v1" }
  #
  config.api_headers = { "Accept" => "application/vnd.marketplace.v1" }

  # Layout configuration
  # config.layout = "sabisu"

  # Resources on the api
  config.resources = ["users"]

  # Default resource
  config.default_resource = "users"

  # Application name
  # mattr_accessor :app_name
  # @@app_name = Rails.application.class.parent_name

  # Authentication
  # mattr_accessor :authentication_username
  # @@authentication_username = "admin"

  # mattr_accessor :authentication_password
  # @@authentication_password = "sekret"
end

2

Create a migration file:

$ rails g migration change_ip_columns_in_users_table

And the generated file should look like:

class ChangeIpColumnsInUsersTable < ActiveRecord::Migration
  def change
    change_column :users, :current_sign_in_ip, :string
    change_column :users, :last_sign_in_ip, :string
  end
end

Run the migrations, restart your rails server and then you should be good to go!

Answer by @jakeatwork on stackoverflow if you want to upvote http://stackoverflow.com/questions/29340177/cant-get-sabisu-gem-to-render-shows-no-input-found-for-inet-error/29340178#29340178

Hope this solves your problem. It worked for me!

levi-l-damian commented 9 years ago

I applied all the changes and it is working perfectly. I am understanding that the matter was related to some columns type in the table users (generated by devise). Many thanks. I also up voted on stack overflow.

On Mon, Apr 20, 2015 at 4:14 PM, Abraham notifications@github.com wrote:

I managed to solve it!

Here is step by step: 1

Change the sabisu_rails.rb initializer:

Use this module to configure the sabisu available options

SabisuRails.setup do |config|

Base uri for posting the

config.base_api_uri = 'api.marketplaceapi.dev'

Ignored attributes for building the forms

config.ignored_attributes = %w{ created_at updated_at id }

HTTP methods

config.http_methods = %w{ GET POST PUT DELETE PATCH }

Headers to include on each request

#

You can configure the api headers fairly easy by just adding the correct headers

config.api_headers = { "Accept" => "application/json,application/vnd.application.v1" }

# config.api_headers = { "Accept" => "application/vnd.marketplace.v1" }

Layout configuration

config.layout = "sabisu"

Resources on the api

config.resources = ["users"]

Default resource

config.default_resource = "users"

Application name

mattr_accessor :app_name

@@app_name = Rails.application.class.parent_name

Authentication

mattr_accessor :authentication_username

@@authentication_username = "admin"

mattr_accessor :authentication_password

@@authentication_password = "sekret"end

2

Create a migration file:

$ rails g migration change_ip_columns_in_users_table

And the generated file should look like:

class ChangeIpColumnsInUsersTable < ActiveRecord::Migration def change change_column :users, :current_sign_in_ip, :string change_column :users, :last_sign_in_ip, :string endend

Run the migrations, restart your rails server and then you should be good to go!

Answer by @jakeatwork https://github.com/jakeatwork on stackoverflow if you want to upvote http://stackoverflow.com/questions/29340177/cant-get-sabisu-gem-to-render-shows-no-input-found-for-inet-error/29340178#29340178

Hope this solves your problem. It worked for me!

— Reply to this email directly or view it on GitHub https://github.com/IcaliaLabs/sabisu-rails/issues/22#issuecomment-94557588 .

Levi

kurenn commented 9 years ago

Yes it was related to input fields, check out https://github.com/IcaliaLabs/sabisu-rails/issues/20#issuecomment-92532235 for more information