Rails

Rails Devise Bootstrap Sign Up modal

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to alter my devise registration view file to work with bootstrap modals. I have followed the bootstrap instructions and slotted the form into the modal and linked it to the navbar menu. Now, when i click on 'Register' in my navbar. Nothing happens. The form doesn't go anywhere. I had this working when it was just a standard page view. Can anyone help? Thank you. I am trying to follow this answer but am getting confused: Twitter Bootstrap Modal not popping up for user login I have: views/devise/shared/registration_items: <% if user

Rails 3: alias_attribute and Unkown column error

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Devise for authentication, so I've aliased a few columns in my legacy database to accommodate it as follows: class User < ActiveRecord::Base set_table_name 'my_legacy_user_table' set_primary_key 'UserId' alias_attribute :id, :UserId alias_attribute :username, :LoginId alias_attribute :encrypted_password, :PasswordSHA1Hash alias_attribute :first_name, :Name alias_attribute :last_name, :Surname devise :database_authenticatable, :authentication_keys => [:username] attr_accessible :username, :password, :password_confirmation def

Selective Rails 3.2 asset pipeline compression per file

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'd like to selectively compress some of the javascript files in a Rails 3.2 app, but still have all js assets served from a single bundled file in the production environment. Syntax like this, inside of the app/assets/javascripts/application.js file, using the made-up :compress => false option passed to the last 3 sprockets require directives I hope explains what I'm trying to achieve. // Contents of app/assets/javascripts/application.js // //= require jquery //= require jquery_ujs //= require angular-1.0.1/angular, :compress => false //=

Are foreign keys in Rails generally avoided?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Rails has no way of creating foreign keys in migrations (there are plugins to do this, however). There are also plenty of cascading options so you can get cascading deletes, for example. With all of these options built in, is it worth creating foreign keys in the database? Is this something Rails developers normally avoid or what? You'd think if it was a recommended practice that Rails would natively support it. 回答1: This is something of a holy issue, because DHH (the creator of Rails) has stated before that he sees the database as

Rails Cache Clearing

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this in my production environment: # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true How do I completely clear the cache so changes I deploy take effect? I have added content to one of the pages but it doesnt seem to show up since I set the config.cache_classes to equal true. Thanks, Danny 回答1: If you use passenger you need to create the file tmp/restart.txt or update its modification time if it's already there: touch tmp/restart.txt 文章来源: Rails Cache

Rails form_for collection_select ignoring remote ajax call that select_tag accepts

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Before getting my form helper working, I was using the below for my select dropdown: <%= select_tag :city_id, options_for_select( City.all.collect{|c| [c.name,c.id]} ), :data => { :remote => true, :url => url_for(:controller => "locations", :action => "filter_by_city") } %> and this worked perfectly to call my filter_by_city.js.erb and update some other values. Inspecting with firebug shows that it has the data-remote, etc, properties. Changing to the form_for helper below, however, I get no data-remote, and thus no AJAX call. <%= f

Rails 4 ajax load content in bootstrap tab

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the same problem as described in this post . However, I still find it hard to comprehend the solution. The view: / Nav tabs % ul . nav . nav - tabs % li . active = link_to "Tab1" , "#tab1" , html_options = { "data-toggle" => "tab" } % li = link_to "Tab2" , "#tab2" , html_options = { "data-toggle" => "tab" } % li = link_to "Tab3" , "#tab3" , html_options = { "data-toggle" => "tab" } / Tab panes . tab - content . tab - pane . active #tab1 % p Fetch content . tab - pane . active #tab2 % ul . nav . nav - pills % li . active = link_to

What is ORM as related to Ruby on Rails?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is ORM as it applies to Rails and what does it mean? 回答1: ORM is Object Relational Mapper. It means you don't have to manually call the database yourself; the ORM handles it for you. Ruby on Rails uses one called ActiveRecord, and it's a really good one. ORM allows you to do things such as: User.find(50).contacts Instead of manually writing a SELECT statement with JOINs, WHEREs, etc. 回答2: ORM stands for Object-Relational-Mapping. It basically means that Active Record takes data which is stored in a database table using rows and columns,

Rails how to create data schema seed data

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to auto generate a seed data file and create seed data like what you would see in Laravel in below link? Laravel Database Migrations & Seed I've seen some timestamped files created under db folder of Rails on another app with timestamp which had seed data included. What would be good approach to create this? 回答1: I suggest you to use the combination of Fabrication gem and Faker . Fabrication allows you to write a pattern to build your objects and Faker gives you fake data like names, emails, phone numbers and so on. This is

Rails 5 API protect_from_forgery

匿名 (未验证) 提交于 2019-12-03 02:57:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Rails 5 API app ( ApplicationController < ActionController::API ). The need came up to add a simple GUI form for one endpoint of this API. Initially I was getting ActionView::Template::Error undefined method protect_against_forgery? when I tried to render the form. I added include ActionController::RequestForgeryProtection and protect_from_forgery with:exception to that endpoint. Which solved that issue as expected. However, when I try to submit this form I get: 422 Unprocessable Entity ActionController::InvalidAuthenticityToken . I