Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `smart_listing_update' #5

Closed
wsouto opened this issue May 24, 2014 · 7 comments
Closed

undefined method `smart_listing_update' #5

wsouto opened this issue May 24, 2014 · 7 comments

Comments

@wsouto
Copy link

wsouto commented May 24, 2014

I getting this error with this line in the index.js.erb file:
<%= smart_listing_update(:persons) %>

I'm new to Rails and probaly misunderstood some point in the README. I just can't see what I'm doing wrong after go through instructions for some many times now. It might be the the helpers missing or something. I'm including the helpers in the app/controllers/application_controller.rb file.

I'm sorry if it's not an issue. I'm on the 1.0.0 version.

@ljachymczyk
Copy link
Member

Hello,

Are you sure following is included in your controller?

include SmartListing::Helper::ControllerExtensions
helper  SmartListing::Helper

@wsouto
Copy link
Author

wsouto commented May 30, 2014

I'm including these lines in the application_controller.rb. I tried in the specific controller too and still got the error.

Since I'm just trying it in a new app, it's not hassle to start over, so I'll go to do that tomorrow and watch carefully all my steps and see for sure if I'm not doing something wrong. I'm closing this issue for now until I got sure if it's me or not. If can't figure it out I'll post every step and the app to reproduce the error too. I'm in the latest Rails 4.1.1 by the way, if that matters.

It's a wonderful gem and really handy I hope I can use it because I have a use case that it just fits... Thank you for this nice gem and keep up with the good work!

@wsouto wsouto closed this as completed May 30, 2014
@wsouto
Copy link
Author

wsouto commented Jun 1, 2014

So, I'm having a hard time trying to figure this out. I started from scratch and keeping having this error because of the <%= smart_listing_update :users %> in the index.js.erb.

I have this in the controller:

class UsersController < ApplicationController
  include SmartListing::Helper::ControllerExtensions
  helper SmartListing::Helper

  def index
    smart_listing_create :users, User.all, partial: "users/list"
  end
end

I did everything else like the instructions. I'm for sure missing something. If I remove the call for <%= smart_listing_update :users %> in the index.js.erb the list works, but I'll be missing features. I've pushed an app to Github that shows the error in case you want to take a look. You can clone it from:

https://github.com/wsouto/smartlisting.git

I just initialized a new Rails app with rails 4.0.5 (I tried also and first with 4.1.1) and follow the steps on README here on Github.

Please, again, sorry if I'm doing something wrong but I just can't figure out... Any help will be thankfully apreciated and I'm really looking forward to use your gem.

Thanks in advance.

@wsouto wsouto reopened this Jun 1, 2014
@marostr
Copy link
Contributor

marostr commented Jun 1, 2014

I looked at your code. First of all, add

//= require smart_listing
to your application.js
and the most important, move index.js.erb from app/assets/javascripts to app/views/users.

@wsouto
Copy link
Author

wsouto commented Jun 2, 2014

Thank you very much @tolhaje !

So the move of index.js.erb to app/views/users did the trick.

I'm aware of the //= require smart_listing, I just messed up too much with the app and removed it hoping for more errors messages that could give me more hints... Sorry about that.

Closing for good now.

@wsouto wsouto closed this as completed Jun 2, 2014
@wkurosawa
Copy link

I was getting same error on my application, I know that this is due to my lack of information, but, also documentation requires you have a prior knowledge about how Rails handle AJAX requests and responses. And I should, of course.

@wsouto I guess the reason why you need to move index.js.erb is because this is like response of User#index method when called with AJAX, so users_controller.rb will look for a js file on views folder.

Am I right?

@wsouto
Copy link
Author

wsouto commented Jun 26, 2014

@wkurosawa You probabilly are. I just didn't have a clue that we could put js files in the views folder since we have all that asset pipeline and specific folder for javascript files... A simple note in the docs telling newbies like me about where to put this particular file could've helped a lot. But it's a newbie way to think. The name of the file itself is a clue, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants