todo-tutorial icon indicating copy to clipboard operation
todo-tutorial copied to clipboard

Some problem when follow this tuto.

Open zw963 opened this issue 8 years ago • 1 comments

Following just the summarize discuss in gitter:

Following is toto error:

  • get '/(*other)', to: 'hyperloop#app', which introduce in Chapter 7, should mention in Chapter 1, other, rails route not worked, I do this myself when follow this tuto, but others maybe not.

  • after rails g hyperloop:install, and then copy application_record.rb into app/hyperloop/models, that not work, uninitialized constant ApplicationRecord, the solution is: add config.import 'models/application_record' into config/initializers/hyperloop.rb, and rm tmp/cache, then worked. this step is done in this project, but when follow tuto, no where told us.

Follow is some advice for hyperloop

Following usage i think is error-prone. EditItem(todo: params.todo).on(:save, :cancel) { mutate.editing false } In most case, :save, :cancel should be browser internal event, If we use a event like this but name conflict with this, what happen? and, use param to define a event is very strange for me.

I think a better idea is: (two selection)

  • Not use on method, not conflict with browser event, you just hope yield one behavior only, use a name other than on is better, or, just simple:
# replace EditItem(todo: params.todo).on(:save, :cancel) { mutate.editing false }
# with

EditItem(
        todo:      params.todo,
        on_save:   proc { mutate.editing false },
        on_cancel: proc { mutate.editing false }
      )

# and invoke it like this:
params.on_save.call
  • Not use param to declare a event. e.g.
def event(name)
  # detect all browser internal support event name, if conflict, raise a error.
  param name, type: Proc
end
event :on_save

I think first solution is better, because params.on_save is just like usual param, it just use logic instead of a variable.

zw963 avatar Jul 30 '17 12:07 zw963

Hi, @catmando , I try to follow Not use on method mentioned in issue, but that not work.

Please see this commit, when I change back to use old usage, it worked.

https://github.com/zw963/hyperloop_todo_example/commit/52e3ede2ca39638a1a11fc8f86ddd428e69400b0

So, I think there exist some weird hack for this.

Could you please explain why it not work before this commit?

Thanks

zw963 avatar Aug 18 '17 17:08 zw963