Rails

Rails flash notice via ajax

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Long story short, I have a button. On clicking it, I want an ajax request to be triggered which gets flash[:notice] and displays it in a div in$ Here is my shortened view: My ajax request in the view: $("#search").submit(function(){ $.ajax({ type: "POST", url: //url to my show action success: function(data){ /*$("#notice").html(""); $("#content").html(data);*/ } }); return false; }); My controller: def HomeController 'search' end end My show.js.erb #app/views/dashboard_home/show.js.erb $("#notice").html(""); $("#content").html(""); The

Ruby on Rails config.secret_token error

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I just started learning ruby on rails. I followed a lot of install examples, but when i ran the example am getting this error A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb I search for it but i dont see too much help. plz help. Platform: Mac OS X. 回答1: The easiest way to generate a new secret token is to run rake secret at the command line. 回答2: Your token should have been generated

Rails / javascript: “too many parameter keys” - what's a good way to normalize form data?

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using rails 3.1.3. I have a form with a lot of fields. When the form is submitted, I get this error ERROR RangeError: exceeded available parameter key space /home/james/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.3.6/lib/rack/utils.rb:99:in `block in parse_nested_query' /home/james/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.3.6/lib/rack/utils.rb:93:in `each' /home/james/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.3.6/lib/rack/utils.rb:93:in `parse_nested_query' /home/james/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.3.6/lib/rack/request.rb:302:in `parse_query' /home

Rails: submit (via AJAX) when drop-down option clicked

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the easiest and most graceful way to auto-submit an AJAX form when a drop-down box's option is selected? I'm creating an administration page where the admin can modify user permissions (where "permissions" is stored as an integer), and I would like the "permissions" field to be a drop-down box that automatically submits and updates when the administrator clicks on the option he wants the user to have. Here's the stripped-down version of what I'm currently looking at. I need to know the best way to convert this to a remote form that

How do I set MySQL as the default database in Rails 3?

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I started using Rails 2 last April but stopped this June because I thought learning it when Rails 3 was released would be more practical since a lot of it was completely refactored and restructured. I used to work with Ubuntu 10.04 (with SQLite3 as the default db) but now I'm using Windows 7 and MySQL 5. I already installed the gem adapter for MySQL, but to use it I still need to tweak database.yml. Thanks. 回答1: In terms of database configuration, nothing much has really changed between Rails 2 and 3 with the exception of how you load your

RubyMine: Rails server launcher wasn't found in the project

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: After importing an existing project into RubyMine, I encountered "Rails server launcher wasn't found in the project" when I Run/Edit Configuration. I've checked this Cannot start the debugger in Rubymine. Rails server launcher wasn't found in project , but deleting the .idea directory and re-open is not helpful. I can rails server in the Terminal successfully and the rails server runs. So I guess it's likely a RubyMine related thing. Thanks, Allen 回答1: I upgraded from RubyMine to IntelliJ Ultimate IDE 2017.1.5 and I encountered the same

How to beautify xml code in rails application

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a simple way to print an unformated xml string to screen in a ruby on rails application? Something like a xml beautifier? 回答1: Ruby core REXML::Document has pretty printing: REXML::Document#write( output=$stdout, indent=-1, transitive=false, ie_hack=false ) indent: An integer. If -1, no indenting will be used; otherwise, the indentation will be twice this number of spaces, and children will be indented an additional amount. For a value of 3, every item will be indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1 An

A rails app which gets users location using HTML5 geolocation and saves to data base

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Seems pretty simple but I'm struggling. Here's what I have so far in the view. I display the location coords just to test its working. But I also want to persist on Database, hence the ajax call. Am I doing this the right way or is there an easier or better way? <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <script> var x=document.getElementById("demo"); var lat; var long; function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition);

Adding a submit button image to a Rails form

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a form in Rails for submitting comments, and I want the submit button to be an image, rather than an HTML button. In this bit of documentation , it says the code is image_submit_tag , but I can't get it to work in my code. Here's what I'm working with: <% form_for [@post, Comment.new], :remote => true do |f| %> <p> <%= f.label :body, "Add a comment" %><br /> Name <%= f.text_field :name %><br /> Website<%= f.text_field :website %><br /> Twitter<%= f.text_field :twitter %><br /> <%= f.text_area :body %> </p> <div id="comment-form"

Ruby on Rails MySQL #08S01Bad handshake - downgrade MySQL?

匿名 (未验证) 提交于 2019-12-03 02:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We recently upgraded from MySQL 5.1.41 to 5.1.61 on our Ubuntu 10.04LTS server. We have an ancient RoR web app that's now giving a bad handshake error: Mysql::Error in MainController#index #08S01Bad handshake /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/vendor/mysql.rb:523:in `read' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/vendor/mysql.rb:153:in `real_connect' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect' /usr/lib/ruby/gems