When I do a post one of the session variables is lost in IE. This webapp works perfectly in Chrome and Firefox. Here is the error: NoMethodError at / undefined method `include?' for nil:NilClass file: welcometo.rb location: xml_file_to_use line: 19 Here is the method that errors: def xml_file_to_use groups = allowed_groups #Which xml file should I write to if (session[:location_group].include? all
軽量Webアプリケーションフレームワーク、SinatraではデフォルトでRackのセッション機能は無効化されている。セッションを有効にするには以下の指定を行う。 これによってアプリケーション内でsession変数が使用可能になる。sessionを使ったアプリケーションの例は以下の通り。ルート/fooでセッションにHello World!という文字列を追加し、別のルート/barでセッションから値を取り出して表示するものだ。 get '/foo' do session[:message] = 'Hello World!' redirect to('/bar') end get '/bar' do session[:message] # => 'Hello World!' end
Ajaxを扱ったことがなかったのと、これの前のエントリーでJSONについて書いたのでそれの自己解決のための記事です。 Ajaxとは何か Ajaxってのは非同期的に処理をして動的に処理をしてくれる技術です。Twitterでツイートしたらページが遷移することなく更新されるアレ。 実際にやってみよう 「Just F**king Do It(とにかくやれ)」の精神で、実際にやってみましょう。タイトルの通り、SinatraとjQueryを使います。SinatraでJSONを生成して、jQueryでAjaxを利用した処理を行います。 どんなのを作るか こんな感じ。フォームに名前を入れたら、フォームに入れた名前と年齢として0~99までの乱数がJSONで返ってきて、それを表示。 サーバサイド app.rb require 'bundler' Bundler.require # Bundler使わない人はこ
I'm building a simple app in ruby using the Sinatra framework. It's mainly "get" based - most requests will be for listing data. However there are a couple of key screens in the app that will collect user input. I want to ensure the app is as safe as I can make it, and currently, trying to find how to implement the kind of authenticity tokens that you get in a Rails form? Where I've got to: Well,
I have a Ruby Sinatra app and I have some code which I need to execute on all routes except for a few exceptions. How do I do this? If I wanted to execute the code on selected routes (whitelist style) I'd do this: ['/join', "/join/*", "/payment/*"].each do |path| before path do #some code end end How do I do it the other way round though (blacklist style)? I want to match all routes except '/join'
Frequently Asked Questions Frequently Asked Questions How do I make my Sinatra app reload on changes? What are my deployment options? How do I use sessions? How do I use session-based flash? Can I run Sinatra under Ruby 1.9? How do I get the “route” for the current page? How do I access helpers from within my views? How do I render partials? Can I have multiple URLs trigger the same route/handler?
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く