railsapps

Select enum from form to set role

心不动则不痛 提交于 2020-01-11 17:56:24
问题 Ruby on Rails 4.1 I am using Devise with enum role. It currently sets a defualt role when the User is created. I want to add a field to the form that creates Users to set the enum role. I read this but it doesn't say how to utilize the new roles. This is the User class devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable enum role: [:user, :vip, :admin, :developer, :marketing, :support, :translator] after_initialize :set_default

Error with RailsApps starter app for rails-devise-roles tutorial

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:52:07
问题 Hello I am trying to install the starter app for rails-devise-roles from RailsApps. I have done one of their previous basic tutorials, but it has been about four months. I'm not sure if I need to update something. I am using a mac with terminal input. When I run this command: ails new rails-devise-roles -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb I get through all the prompts and it starts installing until I get to this error: Gem::Ext::BuildError: ERROR: Failed to

How do you add a nested attribute to permitted parameters for Devise in order for nested form to work

本小妞迷上赌 提交于 2019-12-12 02:58:52
问题 I'm running: rails 4.1.4 devise 3.3 I used the RailsApp starter app to set up devise and pundit. Right now I am having trouble making a nested form attribute save. I am getting an error: Unpermitted parameters: players I edited the initializer file to show: def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :players, :player_attributes => [:position]) } devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name,

Invalid URI Error when using Mailchimp in Rails

半世苍凉 提交于 2019-12-11 04:58:06
问题 Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly) I'm working through the railsapps.org book on learning rails I have finished implementing the mailchimp email list code, and when I press submit on my form, I get the following error: URI::InvalidURIError at /visitors the scheme https does not accept registry part: us8'.api.mailchimp.com (or bad hostname?) My debug screen seems to indicate that it's failing

Issues using config/secrets.yml variable set from ENV variable on Rails 4.1.0

时光怂恿深爱的人放手 提交于 2019-12-11 01:27:03
问题 Have not played with Rails in ages so walking through the Learn Ruby on Rails tutorial which is excellent. I'm having issues with google authentication, the example code calls the config/secrets.yml variables (which are read from ENV in the shell) from the app/models/contact.rb model update_spreadsheet method below def update_spreadsheet connection = GoogleDrive.login(Rails.application.secrets.gmail_username, Rails.application.secrets.gmail_password) I have the ENV variable set via my ~/.bash

Cannot launch rails server - uninitialized constants Sprockets::Rails::VERSION::(NameError)

假如想象 提交于 2019-12-10 17:04:26
问题 I am simply trying to go through the railsapps.org Learn Ruby on Rails book online. I have everything installed and am stuck at "Launching the Web Server" in the tutorial. When I execute '$ rails server', I get the following: trick420$ rails server => Booting WEBrick => Rails 4.1.0 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) =

Select enum from form to set role

房东的猫 提交于 2019-12-02 19:27:10
Ruby on Rails 4.1 I am using Devise with enum role. It currently sets a defualt role when the User is created. I want to add a field to the form that creates Users to set the enum role. I read this but it doesn't say how to utilize the new roles. This is the User class devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable enum role: [:user, :vip, :admin, :developer, :marketing, :support, :translator] after_initialize :set_default_role, :if => :new_record? def set_default_role self.role ||= :user end This is the part of the form

Where is user.admin? defined in rails-devise-pundit starter app?

蹲街弑〆低调 提交于 2019-12-01 22:00:46
问题 I used RailsApps rails-composer to create a rails-devise-pundit starter application. I am still a little new to ruby on rails and newer to devise, pundit and rails 4. I was looking at the code to learn how it works. There are many places in controllers and in policy classes where user.admin? is called. But I can't find the admin? method. I would expect it to be in the User model but it isn't there. Here's the user class: class User < ActiveRecord::Base # Include default devise modules. Others

Wrong color for flash messages under Rails 4.1 with Bootstrap or Foundation

僤鯓⒐⒋嵵緔 提交于 2019-11-30 00:51:30
问题 The following code displays Rails flash messages using Bootstrap 3.0: <%# Rails flash messages styled for Twitter Bootstrap 3.0 %> <% flash.each do |name, msg| %> <% if msg.is_a?(String) %> <div class="alert alert-<%= name == :notice ? "success" : "danger" %>"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <%= content_tag :div, msg, :id => "flash_#{name}" %> </div> <% end %> <% end %> The code is from the article Bootstrap and Rails. Similar code from