Twitter like にgif画像取得 注意 gon(gem)必要ないかもだけど、普通のjsの変数だとエラーが出たので、、 unirest(gem)が必要です。さもなければ、ご自身の気に入っている方法でgetしてください。 実装 <input type="text" class="q"> <div id="giphy"></div> <%= link_to 'Gif画像を追加',get_giphy_path(q:""), remote: true ,class: 'btn',id:"get_giphy"%><br> <script> $("#get_giphy").click(function(){ gon.q=$(".q").val() $("#get_giphy").attr("href", "/words/get_giphy?q="+gon.q) }); </script> link_toを使ってAjax化 クリックされたら class="q" の内容を取得してurlを書き換えそしてAjax化してあるactionを呼ぶだけ $('#giphy').append "<%=j render 'giphy' %>" giphy使ってます def get_giphy gon.q @giphys=[] giphys=Unirest.get "https://api.giphy.com/v1/gifs/search?api_key=your_key&q=#{params[:q]}&limit=25&offset=0&rating=G&lang=en" ...
translator
このブログの人気の投稿
A wonder that banks almost except Japanese ones have maintenance fees or checking fees that force their clients to keep their funds in their accounts of them. The merit of it I think is that banks can prevent their clients withdrawing because of rumors or something silly, but it also makes problems that poor people usually can’t get their bank accounts to keep their money because they don’t have money for several kinds of fees that banks charge so I think Japanese banks are pretty good in this way!
コメント
コメントを投稿