ruby-on-rails-4

Unable to send email as parameter in URL in Rails

拟墨画扇 提交于 2020-12-13 11:41:08
问题 I am writing an API to find users by email_id . I am getting an error while sending the email as a parameter. Routes.rb: Rails.application.routes.draw do namespace :api do resources :users, only: [:show, :index] , param: :email end end When I am sending the email as a parameter then I got an error. The URL is http://localhost:3000/api/users/test@abc.com: ActiveRecord::RecordNotFound in Api::UsersController#show Couldn't find User with 'id'={:email=>"test@abc"} This is my routes path: api

Rails - date_select not allow to choose past date

╄→尐↘猪︶ㄣ 提交于 2020-12-12 11:09:46
问题 I am using the following code <%= f.date_select 'event_date', selected: Date.today, :start_year => Date.today.year, :end_year => Date.today.year + 1 %> I want to ban people from choosing data at a min of 5 days from now. and max of 1 year max. How can i set the date and month? Or should i do this in model validation? 回答1: From this answer: Rails 4 date_field, min and max year? You should be able to give the min and max dates: f.date_select 'event_date', selected: Date.today, min: 5.days.ago,

Rails - date_select not allow to choose past date

雨燕双飞 提交于 2020-12-12 11:09:14
问题 I am using the following code <%= f.date_select 'event_date', selected: Date.today, :start_year => Date.today.year, :end_year => Date.today.year + 1 %> I want to ban people from choosing data at a min of 5 days from now. and max of 1 year max. How can i set the date and month? Or should i do this in model validation? 回答1: From this answer: Rails 4 date_field, min and max year? You should be able to give the min and max dates: f.date_select 'event_date', selected: Date.today, min: 5.days.ago,

How does finger print digest gets calculated in Rails 4.2

徘徊边缘 提交于 2020-12-10 08:57:49
问题 I am using Rails 4.2 and the document states that the fingerprint is an md5 digest calculated based on the content of the compiled file. If we take a file lets say application-4c697a2e67b1a921abbdc1f753c465d8.js , 4c697a2e67b1a921abbdc1f753c465d8 is the md5 digest. The problem is that we are never able to get the same value by generating md5 from the content of the same file. I have read somewhere that this fingerprint is not only based on the file but also affected by the environment along

How does finger print digest gets calculated in Rails 4.2

旧城冷巷雨未停 提交于 2020-12-10 08:56:56
问题 I am using Rails 4.2 and the document states that the fingerprint is an md5 digest calculated based on the content of the compiled file. If we take a file lets say application-4c697a2e67b1a921abbdc1f753c465d8.js , 4c697a2e67b1a921abbdc1f753c465d8 is the md5 digest. The problem is that we are never able to get the same value by generating md5 from the content of the same file. I have read somewhere that this fingerprint is not only based on the file but also affected by the environment along

Multiple require & permit strong parameters rails 4

◇◆丶佛笑我妖孽 提交于 2020-12-05 05:48:22
问题 In the below case, i am trying to use strong parameters. I want to require email_address, password and permit remember_me fields. But using like below it only allows the LAST line in the method Ex:- In below case it only take params.permit(:remember_me) private def registration_params params.require(:email_address) params.require(:password) params.permit(:remember_me) end Another Ex:- In this below case, if i rearrange it like below it will take only params.require(:email_address) where am i

Multiple require & permit strong parameters rails 4

百般思念 提交于 2020-12-05 05:44:11
问题 In the below case, i am trying to use strong parameters. I want to require email_address, password and permit remember_me fields. But using like below it only allows the LAST line in the method Ex:- In below case it only take params.permit(:remember_me) private def registration_params params.require(:email_address) params.require(:password) params.permit(:remember_me) end Another Ex:- In this below case, if i rearrange it like below it will take only params.require(:email_address) where am i

Multiple require & permit strong parameters rails 4

旧城冷巷雨未停 提交于 2020-12-05 05:44:05
问题 In the below case, i am trying to use strong parameters. I want to require email_address, password and permit remember_me fields. But using like below it only allows the LAST line in the method Ex:- In below case it only take params.permit(:remember_me) private def registration_params params.require(:email_address) params.require(:password) params.permit(:remember_me) end Another Ex:- In this below case, if i rearrange it like below it will take only params.require(:email_address) where am i

How do I have a persistent file storage when deploying to Heroku?

随声附和 提交于 2020-11-25 03:46:52
问题 I know that Heroku's dyno gets refreshed each time a deploy is made so is there anyway I can have my files persistent or there's no other way but use services like amazon S3? I use paperclip to handle file upload and most of the files will be in pdf. 回答1: It would be best to use S3 or another service. Ephemeral filesystem Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as

How do I have a persistent file storage when deploying to Heroku?

北慕城南 提交于 2020-11-25 03:44:22
问题 I know that Heroku's dyno gets refreshed each time a deploy is made so is there anyway I can have my files persistent or there's no other way but use services like amazon S3? I use paperclip to handle file upload and most of the files will be in pdf. 回答1: It would be best to use S3 or another service. Ephemeral filesystem Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as