Search code examples
jrubyshoes

Issue while calling particular method inside button block in shoes4


While calling method inside button block in SHoes4 it throws error  undefined local variable or method `get_notes' . But when i call inside action it works fine,

Code:

class ShoesApp
 include Shoes
    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    # error      
        end         
      end
      @@result = para get_notes # Works fine
    end

    def get_notes
      Note.all.map(&:message).join("\n")
    end
end

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

Solution

  • thanks for reporting this issue.

    After adjusting your script to the current shoes4 master (e.g. < Shoes instead of include Shoes for backwards compatibility) the script errors with stack level too deep, which is related to the way URL system works at the moment (forwarding messages). The URL system is also prime for refactoring, which will hopefully happen within the next 7 days.

    Please keep in mind that shoes4 is still in development and in a pre-alpha stage. So it's not really ready for productive use yet.

    In the future, you'll probably also have more luck reporting issues at the shoes4 issue tracker due to better visibility. I just popped by hear by accident. I went ahead and created an issue there

    Cheers and hope you enjoy shoes so far,

    Tobi

    edit: oh yes by the way, in general you should really avoid using class variables (@@) they often behave weird and are generally not considered good practice, but that's not really connected to the problem

    edit2: another thing is that the Note class seems to be missing, although it appears to be like it was built in with Shoes3. Not sure if we're gonna keep the compatibility.