These are chat archives for padrino/padrino-framework

14th
Feb 2016
Matthias Günther
@wikimatze
Feb 14 2016 06:12
Small IRC test
padrinobot
@padrinobot
Feb 14 2016 07:23
wikimatze Test if that works
Matthias Günther
@wikimatze
Feb 14 2016 07:23
It seems to work
padrinobot
@padrinobot
Feb 14 2016 07:24
wikimatze Juhu, it works
Matthias Günther
@wikimatze
Feb 14 2016 07:31
Yeah the bot is away
padrinobot
@padrinobot
Feb 14 2016 07:31
wikimatze bot is there again
Matthias Günther
@wikimatze
Feb 14 2016 07:31
I can see this
Matthias Günther
@wikimatze
Feb 14 2016 07:37
And another test
Matthias Günther
@wikimatze
Feb 14 2016 08:02
heroku doesn't seem to work
Joshua Cave
@jaybeecave
Feb 14 2016 08:46
can anyone help me with something im stuck on
trying to write a bit of code like form_for
<%GridHelper.grid(@page.id, 12) do%>
<%=GridHelper.item "grid-1", 0, 0, 4, 2%>
<%=GridHelper.item "grid-2", 4, 0, 4, 4%>
<%=GridHelper.item "grid-3", 8, 0, 2, 2%>
<%=GridHelper.item "grid-4", 10, 0, 2, 2%>
<%=GridHelper.item "grid-5", 0, 2, 2, 2%>
<%=GridHelper.item "grid-6", 2, 2, 2, 4%>
<%=GridHelper.item "grid-7", 8, 2, 4, 2%>
<%=GridHelper.item "grid-8", 0, 4, 2, 2%>
<%=GridHelper.item "grid-9", 4, 4, 4, 2%>
<%=GridHelper.item "grid-10", 8, 4, 2, 2%>
<%=GridHelper.item "grid-11", 10, 4, 2, 2%>
<% end %>
oops
<%GridHelper.grid(@page.id, 12) do%> <%=GridHelper.item "grid-1", 0, 0, 4, 2%> <%=GridHelper.item "grid-2", 4, 0, 4, 4%> <%=GridHelper.item "grid-3", 8, 0, 2, 2%> <%=GridHelper.item "grid-4", 10, 0, 2, 2%> <%=GridHelper.item "grid-5", 0, 2, 2, 2%> <%=GridHelper.item "grid-6", 2, 2, 2, 4%> <%=GridHelper.item "grid-7", 8, 2, 4, 2%> <%=GridHelper.item "grid-8", 0, 4, 2, 2%> <%=GridHelper.item "grid-9", 4, 4, 4, 2%> <%=GridHelper.item "grid-10", 8, 4, 2, 2%> <%=GridHelper.item "grid-11", 10, 4, 2, 2%> <% end %>
I want to use capture_html to grab the items between the gridhelper block
so if i call

module AzurixWebsite
class App
module GridHelper
def self.grid(page_id, cols, &block)
block_html = capture_html(What_Do_I_Put Here, block)
html = "<div class='grid-stack' data-gs-width='#{cols}' data-gs-animate='yes'>#{block_html}</div>"
html
end

  def self.item(grid_id, x, y, width, height)
    return "div>#{grid_id}</div>"
  end
end

helpers GridHelper

end
end

module AzurixWebsite
  class App
    module GridHelper
      def self.grid(page_id, cols, &block)
        block_html = capture_html(What_Do_I_Put Here, block)
        html = "<div class='grid-stack' data-gs-width='#{cols}' data-gs-animate='yes'>#{block_html}</div>"
        html
      end

      def self.item(grid_id, x, y, width, height)
        return "div>#{grid_id}</div>"
      end
    end

    helpers GridHelper
  end
end
<%GridHelper.grid(@page.id, 12) do%>
<%=GridHelper.item "grid-1", 0, 0, 4, 2%>
<%=GridHelper.item "grid-2", 4, 0, 4, 4%>
<%=GridHelper.item "grid-3", 8, 0, 2, 2%>
<%=GridHelper.item "grid-4", 10, 0, 2, 2%>
<%=GridHelper.item "grid-5", 0, 2, 2, 2%>
<%=GridHelper.item "grid-6", 2, 2, 2, 4%>
<%=GridHelper.item "grid-7", 8, 2, 4, 2%>
<%=GridHelper.item "grid-8", 0, 4, 2, 2%>
<%=GridHelper.item "grid-9", 4, 4, 4, 2%>
<%=GridHelper.item "grid-10", 8, 4, 2, 2%>
<%=GridHelper.item "grid-11", 10, 4, 2, 2%>
<% end %>
wow this is messy sorry
Joshua Cave
@jaybeecave
Feb 14 2016 08:52
so I dont know what to put in *args for capture_html
Matthias Günther
@wikimatze
Feb 14 2016 09:31
bot test
Matthias Günther
@wikimatze
Feb 14 2016 09:42
Hi @cavej03, try capture_html { "<foo>" } - it must be a block
hope that may help you in some way
Joshua Cave
@jaybeecave
Feb 14 2016 09:43
struggling to get the require right
i cant seem to use capture_html anyways
 require 'padrino-helpers/output_helpers'
sorry the question above was so messy
Matthias Günther
@wikimatze
Feb 14 2016 09:59
Yeah, so https://github.com/padrino/padrino-framework/blob/master/padrino-helpers/lib/padrino-helpers/output_helpers.rb#L61 should be the right place. I don't think that you have to include something like this
Joshua Cave
@jaybeecave
Feb 14 2016 09:59
im determined to figure it so im going back to how i had it
but I cannot call capture_html from inside that helper
how do i register Padrino::Helpers::OutputHelpers
Matthias Günther
@wikimatze
Feb 14 2016 10:04
Have you tried:
irb
>> require 'padrino-helpers'
=> true
>> Padrino::Helpers::OutputHelpers
=> Padrino::Helpers::OutputHelpers
Joshua Cave
@jaybeecave
Feb 14 2016 10:05
I just tried it in a controller
rather than in a helper
and it works
trying above now
padrinobot
@padrinobot
Feb 14 2016 10:07
wikimatze this should normally work ..
Joshua Cave
@jaybeecave
Feb 14 2016 10:08
i just tried
require 'padrino-helpers’ in irb
and got
uninitialized constant Padrino::Rendering::Tilt
padrinobot
@padrinobot
Feb 14 2016 10:09
wikimatze which version of Padrino are you using?
Joshua Cave
@jaybeecave
Feb 14 2016 10:09
13
0.13.0 to be preisise sorry
padrinobot
@padrinobot
Feb 14 2016 10:10
wikimatze ahh, I have Padrino v. 0.12.5
wikimatze can you try to downgrade?
Joshua Cave
@jaybeecave
Feb 14 2016 10:10
yep will do
padrinobot
@padrinobot
Feb 14 2016 10:10
wikimatze maybe it's a problem on the newest version
Joshua Cave
@jaybeecave
Feb 14 2016 10:10
yea i need to figure it out though to report it
so i should normally be able to just use capture_html
in a helper
hmm downgraded and its still pointing to 13
oh wait
dont worry
i didnt downgrade in ruby just in gemfile
padrinobot
@padrinobot
Feb 14 2016 10:13
wikimatze Gemfile.lock
wikimatze restart app
Joshua Cave
@jaybeecave
Feb 14 2016 10:14
i just tried irb again
padrinobot
@padrinobot
Feb 14 2016 10:14
wikimatze do you use bundle?
Joshua Cave
@jaybeecave
Feb 14 2016 10:14
yea
but yea will try app
my app is at 0.12.5
now
but irb is still at 13 of course.
had a moment ^^
hmm still not working
i could just be doing something stupid
Joshua Cave
@jaybeecave
Feb 14 2016 10:20
require 'padrino-helpers'

module AzurixWebsite
  class App
    register Padrino::Helpers::OutputHelpers
    module GridHelper

      def self.grid(page, cols, &block)
        @page = page
        block_html = Padrino::Helperscapture_html(block)
        binding.pry
        html = "<div class='grid-stack' data-gs-width='#{cols}' data-gs-animate='yes'>#{block_html}</div>"
        return html.html_safe
      end

      def self.item(grid_id, x, y, width, height)
        @html << "<div id='#{grid_id}' class='grid-stack-item pull-left' data-gs-x='#{x}' data-gs-y='#{y}' data-gs-width='#{width}' data-gs-height='#{height}'>"
        @html << TextblockHelper.by_page(@page.id, grid_id)
        @html << "</div>\n"
      end
    end

    helpers GridHelper
  end
end
does that look correct?
oops i mean
require 'padrino-helpers'

module AzurixWebsite
  class App
    register Padrino::Helpers::OutputHelpers
    module GridHelper

      def self.grid(page, cols, &block)
        @page = page
        block_html = capture_html(block)
        binding.pry
        html = "<div class='grid-stack' data-gs-width='#{cols}' data-gs-animate='yes'>#{block_html}</div>"
        return html.html_safe
      end

      def self.item(grid_id, x, y, width, height)
        @html << "<div id='#{grid_id}' class='grid-stack-item pull-left' data-gs-x='#{x}' data-gs-y='#{y}' data-gs-width='#{width}' data-gs-height='#{height}'>"
        @html << TextblockHelper.by_page(@page.id, grid_id)
        @html << "</div>\n"
      end
    end

    helpers GridHelper
  end
end
Matthias Günther
@wikimatze
Feb 14 2016 10:22
Does the require and Padrino::Helpers::OutputHelpers works in IRB on your machine?
the code above looks correct in my eyes
Joshua Cave
@jaybeecave
Feb 14 2016 10:22
ill downgrade my irb
to 12.5
Matthias Günther
@wikimatze
Feb 14 2016 10:25
did you can to binding.pry?
Joshua Cave
@jaybeecave
Feb 14 2016 10:28
same error in 12.5
Untitled.png
must be my ruby version
still dont understand why it works in controller and not in helper
padrinobot
@padrinobot
Feb 14 2016 10:32
wikimatze sound like a scope problem ..
Joshua Cave
@jaybeecave
Feb 14 2016 10:33
yes
padrinobot
@padrinobot
Feb 14 2016 10:33
wikimatze maybe helpers are registered before that output helpers
wikimatze had issues with helpers too but no one like this one
Joshua Cave
@jaybeecave
Feb 14 2016 10:33
what if i separate it into lib
as a seperate class
padrinobot
@padrinobot
Feb 14 2016 10:41
wikimatze sounds like a good idea
Matthias Günther
@wikimatze
Feb 14 2016 10:45
wm@wm ~/git/gitter-irc-bot (master ✔) » ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux]
wm@wm ~/git/gitter-irc-bot (master ✔) » padrino --version
Padrino v. 0.12.5
I have another ruby version
Joshua Cave
@jaybeecave
Feb 14 2016 10:46
yea
really frustrating
Matthias Günther
@wikimatze
Feb 14 2016 10:46
can your switch with rvm?
Joshua Cave
@jaybeecave
Feb 14 2016 10:46
yea course
Matthias Günther
@wikimatze
Feb 14 2016 10:47
try it please
Joshua Cave
@jaybeecave
Feb 14 2016 10:47
yea trying now
Joshua Cave
@jaybeecave
Feb 14 2016 10:55
same
i think that method is off limits out side the scope of a controller
or a view
Joshua Cave
@jaybeecave
Feb 14 2016 11:00
actually that makes no sense because form_for isn’t a controller function
method*
Matthias Günther
@wikimatze
Feb 14 2016 11:03
have you tried registering the outputs helper in apps.rb?
Joshua Cave
@jaybeecave
Feb 14 2016 11:03
app.rb
?
Matthias Günther
@wikimatze
Feb 14 2016 11:03
yeah, app.rb
Joshua Cave
@jaybeecave
Feb 14 2016 11:03
posibly not
Matthias Günther
@wikimatze
Feb 14 2016 11:03
module JobVacancy
  class App < Padrino::Application
    use ActiveRecord::ConnectionAdapters::ConnectionManagement
    register Padrino::Rendering
    register Padrino::Mailer
    register Padrino::Helpers
Joshua Cave
@jaybeecave
Feb 14 2016 11:03
register Padrino::Helpers
is there
so you can call that method in a helper?
Matthias Günther
@wikimatze
Feb 14 2016 11:04
and register Padrino::Helpers::OutputHelpers
Joshua Cave
@jaybeecave
Feb 14 2016 11:09
Screen Shot 2016-02-15 at 12.08.51 AM.png
padrinobot
@padrinobot
Feb 14 2016 11:10
wikimatze look like it should work
Joshua Cave
@jaybeecave
Feb 14 2016 11:11
yea
i have no clue
as to what is wrong
can you call that method?
in a random helper?
oh wow there is an example of what im trying to achive here
seems like i shouldn’t need to register anything
Matthias Günther
@wikimatze
Feb 14 2016 11:18
give me a second
Joshua Cave
@jaybeecave
Feb 14 2016 11:18
dont worry man
just tried in the admin
worked fine
oh wow
wow wow wow
it was how i was calling it
Matthias Günther
@wikimatze
Feb 14 2016 11:19
ok, yeah it'S working on my app
Joshua Cave
@jaybeecave
Feb 14 2016 11:19
GridHelper.item
Matthias Günther
@wikimatze
Feb 14 2016 11:19
glad that I could help you
Joshua Cave
@jaybeecave
Feb 14 2016 11:19
vs just calling item
Matthias Günther
@wikimatze
Feb 14 2016 11:19
hehehe
Joshua Cave
@jaybeecave
Feb 14 2016 11:20
i wasted both our time...
Matthias Günther
@wikimatze
Feb 14 2016 11:20
pair programming can/will help
in such situations
Joshua Cave
@jaybeecave
Feb 14 2016 11:20
still new to ruby
silly mistake to make
how is the book going?
Matthias Günther
@wikimatze
Feb 14 2016 11:26
haven't written as much as I wanted => building up the new website took time.
Joshua Cave
@jaybeecave
Feb 14 2016 11:26
the book website
or the refresh on main site?
padrinobot
@padrinobot
Feb 14 2016 11:30
wikimatze And building up some infrastructure for padrino like the padrinobot
Matthias Günther
@wikimatze
Feb 14 2016 11:30
both :smile:
But main-site first
Joshua Cave
@jaybeecave
Feb 14 2016 11:31
yea good to see that thing up
been waitng for it to hit for a while
ive seen the padrino bot doing its stuff
dont quite get how to use it though
Matthias Günther
@wikimatze
Feb 14 2016 11:31
yeah the bot had always my name and pic
Joshua Cave
@jaybeecave
Feb 14 2016 11:32
Oh I see
padrinobot
@padrinobot
Feb 14 2016 11:32
wikimatze and now IRC in terminal and web is working!
wikimatze at work i prefer using IRC
Joshua Cave
@jaybeecave
Feb 14 2016 11:33
haven’t used irc in years
Joshua Cave
@jaybeecave
Feb 14 2016 11:57
thank you for all your help
final result (or atleast final from what you helped me with)
Untitled 2.png
looks a bit broken
but its a drag and drop grid layout
with editable text
im off to bed
thanks again
Matthias Günther
@wikimatze
Feb 14 2016 12:17
Nice, looks great!
padrinobot
@padrinobot
Feb 14 2016 12:35
wikimatze Bot is running
Matthias Günther
@wikimatze
Feb 14 2016 12:35
On uberspace
padrinobot
@padrinobot
Feb 14 2016 12:35
wikimatze and it still runs after closed ssh session
wikimatze finally
padrinobot
@padrinobot
Feb 14 2016 13:09
wikimatze think the bot stil runs, let's check the log
padrinobot
@padrinobot
Feb 14 2016 13:44
intrigueD bot-tastic!
Matthias Günther
@wikimatze
Feb 14 2016 13:45
hehehe
mission accomplished
padrinobot
@padrinobot
Feb 14 2016 13:45
intrigueD what commands does padrinobot respond_to?
intrigueD oops ruby muscle memory kicked in ^^
wikimatze in just syncs IRC terminal and gitter
Matthias Günther
@wikimatze
Feb 14 2016 13:49
making both worlds happy
padrinobot
@padrinobot
Feb 14 2016 13:50
intrigueD so gitter traffic comes in here? and what i'm saying goes in gitter?
intrigueD padrinobot just relays it all?
wikimatze jup
intrigueD padrinobot is a spy
wikimatze a synchronize spy :)
intrigueD a double (channel) agent?
wikimatze yes, but what is said in IRC will be lost without it, so we have a nice history on gitter