ruby-on-rails-3.2

How to lock users using Devise?

安稳与你 提交于 2019-12-01 15:43:29
I want to add a subscription type functionality in my application for the account holder users such that after a fixed interval of time they will not be able to access their account? Note: I dont want to delete their account from the database. I've already installed devise-2.1.2 in my application. Do any body have any idea how can it be done? I am newbie to Ruby on rails so it will be very helpful to me if you please explain the steps. Devise have a buil-in solution with the :lockable option check in the Devise Lockable Documentation You have to set the lock_strategy set to :failed_attempts.

Wicked PDF +fonts+heroku+rails3.2

喜你入骨 提交于 2019-12-01 15:24:01
I'm using wicked_pdf with rails 3.2.11 and ruby 1.9.3 to generate a PDF from HTML and deploying to Heroku. My pdf.css.scss.erb: <% app_fullhost = Constants["app_fullhost"] %> @font-face { font-family:'DosisMedium'; font-style:normal; font-weight:500; src: url(<%=app_fullhost%>/app/font/dosis/Dosis-Medium.ttf) format('woff'); } *, body { font-family: "DosisLight", 'Times New Roman', 'Arial', sans-serif; } where app_fullhost is the exact host, in development or production. My pdf layout includes among other things : %html{:lang => I18n.locale} %head %meta{:charset => "utf-8"} %title= content_for

Bundler could not find compatible versions for gem “activesupport”

会有一股神秘感。 提交于 2019-12-01 15:17:36
问题 I migrated to 3.2.13 version of rails and I am getting this error, how do I get rid of this? Fetching gem metadata from https://rubygems.org/....... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Bundler could not find compatible versions for gem "activesupport": In snapshot (Gemfile.lock): activesupport (3.2.12) In Gemfile: rails (= 3.2.13) ruby depends on activesupport (= 3.2.13) ruby Running `bundle update` will rebuild your snapshot from scratch, using only

Wicked PDF +fonts+heroku+rails3.2

南笙酒味 提交于 2019-12-01 15:13:58
问题 I'm using wicked_pdf with rails 3.2.11 and ruby 1.9.3 to generate a PDF from HTML and deploying to Heroku. My pdf.css.scss.erb: <% app_fullhost = Constants["app_fullhost"] %> @font-face { font-family:'DosisMedium'; font-style:normal; font-weight:500; src: url(<%=app_fullhost%>/app/font/dosis/Dosis-Medium.ttf) format('woff'); } *, body { font-family: "DosisLight", 'Times New Roman', 'Arial', sans-serif; } where app_fullhost is the exact host, in development or production. My pdf layout

Uninitialized constant “Controller Name”

帅比萌擦擦* 提交于 2019-12-01 15:06:40
I'm having an error with my routes/resources and controllers. I have the following in the routes.rb: # routes.rb resources :users do resource :schedule end And I have a schedule_controller.rb inside controllers/users/ set up as I think it should be: class Users::ScheduleController < ApplicationController # Controller methods here... end Running a rake:routes shows user_schedule POST /users/:user_id/schedule(.:format) schedules#create new_user_schedule GET /users/:user_id/schedule/new(.:format) schedules#new edit_user_schedule GET /users/:user_id/schedule/edit(.:format) schedules#edit GET

How to lock users using Devise?

这一生的挚爱 提交于 2019-12-01 14:41:08
问题 I want to add a subscription type functionality in my application for the account holder users such that with few failed login attempts they will not be able to access their account. Note: I don't want to delete their account from the database. I've already installed devise-2.1.2 in my application. Do any body have any idea how can it be done? I am newbie to Ruby on rails so it will be very helpful to me if you please explain the steps. 回答1: Devise have a buil-in solution with the :lockable

why image-path is not resolved in scss?

北城以北 提交于 2019-12-01 14:12:51
in my app, I have a scss file, resulted from a gem, resident in the gem folder out side of my app project folder in works just fine locally, I have the path to images correct, like this: (copied from element inspector at chrome) media="all" .social-share-button-twitter { display: inline-block; width: 16px; height: 16px; background: url("/assets/sprites/social-share-button.png") 0px -48px no-repeat; } but, when I deploy to heroku, the image-path is not resolved, I get this result: media="all" .social-share-button-twitter { display: inline-block; width: 16px; height: 16px; background: url(image

Rails 3.2 create a form that's used in the footer of every page

瘦欲@ 提交于 2019-12-01 14:03:58
I want to create a form that's used to sign up to a mailing list in the footer of my webpage. What I did was create a partial that renders this small form in the footer of the application layout. Here is the code for the partial: <%= form_for(@mailing_list) do |f| %> <% if @mailing_list.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@mailing_list.errors.count, "error") %> prohibited this mailing_list from being saved:</h2> <ul> <% @mailing_list.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :first_name %

in rails how to limit users post count saved in database before asking to upgrade their account

冷暖自知 提交于 2019-12-01 11:56:13
I'm adding a small way of controlling a non-subscribed user and a subscribed user. Basically my idea is that all users that sign up with the use of Devise, get an account. However, my model or the number of posts a user can have in the database stored based on user ID found should be 25 posts. I'm guessing the following would work; Model class Post belongs_to :user validate :quota, :on => :refresh def quota Posts = Posts.find(params[:id]) if user.posts.count >= 25 flash[:error] = "Sorry you need to upgrade" end end end :refresh is something I'm working on where it grabs posts and adds these

Rails HABTM with checkboxes

旧时模样 提交于 2019-12-01 11:51:52
I have three tables, accounts, campaigns and accounts_campaigns. I want to have checkboxes for select accounts in the campaigns edit form. I have Campaign's model like this: class Campaign < ActiveRecord::Base has_and_belongs_to_many :accounts accepts_nested_attributes_for :accounts end I think i dont need to define the relationship on Account. And my form is: = hidden_field_tag "campaign[accounts_ids][]", nil - Account.all.each do |account| %label.checkbox = check_box_tag "campaign[accounts_ids][]", account.id, @campaign.account_ids.include?(account.id), id: dom_id(account) = "#{account.name}