Tag:Rails

  • Making RSS feed code with rails

    Time:2022-3-28

    Method a:It is you who put together the RSS XML format and output it Set the HTTP header and mark the content type as application / XML. Common codes: Copy codeThe code is as follows: #Post_controller::feed() def feed require “rss” articles = Article.find :all, :order => ‘post_date DESC’, :limit => 10 feed = RSS::Maker.make(“2.0”) do […]

  • JQuery in Ruby on rails_ Solving the problem of UJs component slowing down

    Time:2022-2-7

    jquery_ UJs is a very important component for rails, which is included in the default components of rails. Jquery UJs contains some very convenient functions, such as confirmation dialog box, triggering Ajax, automatically disabling form submission button, etc. This paper mainly discusses the function of triggering Ajax. By adding simple tag attributes, jQuery UJs can […]

  • Research on some methods to optimize the performance of Ruby on rails

    Time:2022-2-5

    1. Cause yourRailsThere are two reasons why applications slow down: Should not beRubyAnd rails as the preferred place to use Ruby and rails. (doing something you’re not good at with ruby and rails) Excessive memory consumption leads to the need to use a lot of time for garbage collection. Rails is a pleasant framework, and […]

  • Ruby on rails realizes payment on Ping + + platform

    Time:2022-1-29

    Create an order table from the local database. It is recommended to include the following fields. Refer to the official API( https://pingxx.com/document/api#api -c-new): order_no:required ? 1 2 3 4 5 6 7 8 9 10 The merchant order number, which adapts to the requirements of each channel for this parameter, must be unique in the […]

  • New project of Ruby on rails Foundation

    Time:2022-1-28

    Ruby on Railsdirectory structure ? 1 2 3 4 5 6 7 8 9 10 11 + app/ #Controller, model, view, help method, mail, static resource + bin/ #Rails script + config/ #Routing, database, etc + db/   #Database schema, migration file + lib/  #Expansion module + log/  #Log + public/ #Public resources + test/  #Unit […]

  • Using RVM to control and switch ruby / rails versions

    Time:2021-11-6

    In the process of learning Ruby on rails, different tutorials use different versions of ruby and rails. In order to keep consistent with the versions used in the tutorials, we can use RVM (Ruby Version manager) to control the current ruby / rails version for easy switching. The installation of RVM is not the focus […]

  • Rails implements field encrypted storage

    Time:2021-10-30

    programme Before storage, it is encrypted and then stored in the databaseAfter reading, decrypt with key realization Activesupport:: messageencryptor is a class implemented by rails based on OpenSSL encapsulation. It can be used to encrypt and decrypt an object. For example: ? 1 2 3 4 5 salt = SecureRandom.random_bytes(64) key  = ActiveSupport::KeyGenerator.new(‘password’).generate_key(salt) # => […]

  • Using UTF-8 to solve the problems in Ruby on rails program

    Time:2020-4-30

    1. Save. RB file and. Rhtml file to UTF-8 format;2. Add the following code to / APP / controller / application.rb:Ruby code Copy codeThe code is as follows: before_filter :set_charset def set_charset headers[“Content-Type”] = “text/html; charset=UTF-8” end

  • Solutions to rails “no route matches” errors

    Time:2020-4-29

    Sometimes rails appears:“No route matches” error,It can be solved by the following methods:;Find the config / routes.rb file, open it for editing, and find the following line:# See how all your routes lay out with “rake routes” Add a line below this line as follows:map.connect ”,:controller=>”index”,:action=>”index” No such file to load MySQL Copy codeThe code […]

  • How to connect rails to MySQL

    Time:2020-4-28

    The specified module could not be found. – c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.soThe DLL file required for the connection could not be found: libmysql.dllCopy this file to Ruby bin directory under MySQL installation directory to solve this problem

  • Rails link? To explain

    Time:2020-4-27

    example:code:<%= link_to “Issues”, {:controller => “issue”, :action => “index”}, {:title => “Issues”} %> In fact, the attributes of HTML elements can be set in this way. For example, add a click event processing:code:<%= link_to “Issues”, {:controller => “issue”, :action => “index”}, {:onclick => “alert(1)”} %> But it is worth noting that the second parameter of […]

  • Ruby on rails code tips

    Time:2020-4-22

    Git warehouse outputgit archive –format=tar –prefix=actasfavor/ HEAD | (cd /home/holin/work/ && tar xf -) Output to / home / holin / work / actasfavor / Posted by holin At May 16, 2008 16:42 Loading controllers and models in plugins # Include hook code here require ‘act_as_favor’ # make plugin controller, model, helper available to app […]