Google Calendar Ruby API insert_event errors "each_with_index" undefined - ruby

I'm copying and pasting the code from the Ruby Quickstart and combining it with the create-events code sample from here.
The only things I changed were:
the SCOPE from Google::Apis::CalendarV3::AUTH_CALENDAR_READONLY to Google::Apis::CalendarV3::AUTH_CALENDAR_READ
from client to service in the call to .insert_event('primary', event)
Despite this, I'm getting the error:
.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:38:in `call': undefined method `each_with_index' for nil:NilClass (NoMethodError)
This is befuddling, none more so than knowing it was working earlier. Is there something obviously wrong in the example that I'm not catching? Or did representable or the api-client cop out all of a sudden?
Are folks able to reproduce the problem? Here's my code along with my Gemfile.lock
require "google/apis/calendar_v3"
require "googleauth"
require "googleauth/stores/file_token_store"
require "date"
require "fileutils"
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
APPLICATION_NAME = "Google Calendar API Ruby Quickstart".freeze
CREDENTIALS_PATH = "credentials.json".freeze
# The file token.yaml stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
TOKEN_PATH = "token.yaml".freeze
SCOPE = Google::Apis::CalendarV3::AUTH_CALENDAR
##
# Ensure valid credentials, either by restoring from the saved credentials
# files or intitiating an OAuth2 authorization. If authorization is required,
# the user's default browser will be launched to approve the request.
#
# #return [Google::Auth::UserRefreshCredentials] OAuth2 credentials
def authorize
client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH
token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH
authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store
user_id = "default"
credentials = authorizer.get_credentials user_id
if credentials.nil?
url = authorizer.get_authorization_url base_url: OOB_URI
puts "Open the following URL in the browser and enter the " \
"resulting code after authorization:\n" + url
code = gets
credentials = authorizer.get_and_store_credentials_from_code(
user_id: user_id, code: code, base_url: OOB_URI
)
end
credentials
end
# Initialize the API
service = Google::Apis::CalendarV3::CalendarService.new
service.client_options.application_name = APPLICATION_NAME
service.authorization = authorize
event = Google::Apis::CalendarV3::Event.new(
summary: 'Google I/O 2015',
location: '800 Howard St., San Francisco, CA 94103',
description: 'A chance to hear more about Google\'s developer products.',
start: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T09:00:00-07:00',
time_zone: 'America/Los_Angeles'
),
end: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T17:00:00-07:00',
time_zone: 'America/Los_Angeles'
),
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
Google::Apis::CalendarV3::EventAttendee.new(
email: 'lpage#example.com'
),
Google::Apis::CalendarV3::EventAttendee.new(
email: 'sbrin#example.com'
)
],
reminders: Google::Apis::CalendarV3::Event::Reminders.new(
use_default: false,
overrides: [
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'email',
minutes: 24 * 60
),
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'popup',
minutes: 10
)
]
)
)
result = service.insert_event('primary', event)
puts "Event created: #{result.html_link}"
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
concurrent-ruby (1.1.8)
declarative (0.0.20)
declarative-option (0.1.1)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
gems (1.2.0)
google-api-client (0.53.0)
google-apis-core (~> 0.1)
google-apis-generator (~> 0.1)
google-apis-core (0.3.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.14)
httpclient (>= 2.8.1, < 3.0)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
rexml
signet (~> 0.14)
webrick
google-apis-discovery_v1 (0.2.0)
google-apis-core (~> 0.1)
google-apis-generator (0.2.0)
activesupport (>= 5.0)
gems (~> 1.2)
google-apis-core (~> 0.1)
google-apis-discovery_v1 (~> 0.0)
thor (>= 0.20, < 2.a)
googleauth (0.16.0)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.14)
httpclient (2.8.3)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
jwt (2.2.2)
memoist (0.16.2)
mini_mime (1.0.2)
minitest (5.14.4)
multi_json (1.15.0)
multipart-post (2.1.1)
os (1.1.1)
public_suffix (4.0.6)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.4)
ruby2_keywords (0.0.4)
signet (0.15.0)
addressable (~> 2.3)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
thor (1.1.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
uber (0.1.0)
webrick (1.7.0)
zeitwerk (2.4.2)
PLATFORMS
ruby
DEPENDENCIES
google-api-client
BUNDLED WITH
2.1.4

so we have the same issue with google storage api after they updated it to 1.31. So we downgraded it to 1.29.1. Please, try to downgrade your version too, it will problably work!
And we needed to clear our heroku cache and reinstall all the gems again.
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache
Hope it helps

Related

Active Admin Editor not running

I am trying to include an editor in an Active Admin setting.
I am able to bundle install every version of it up to 1.1.0, but when I run rails s and try to access the admin page I get the following error:
Sass::SyntaxError in Admin/keywords#index
Showing /Users/xxxxx/.rvm/gems/xxxxx/gems/activeadmin-0.6.0/app/views/active_admin/resource/index.html.arb where line #1 raised:
File to import not found or unreadable: ../functions/linear-gradient.
Load path: Sass::Rails::Importer(/Users/xxxxx/.rvm/gems/xxxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
(in /Users/xxxxx/.rvm/gems/xxxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
ActionView::Template::Error (File to import not found or unreadable: ../functions/linear-gradient.
Load path: Sass::Rails::Importer(/Users/xxxx/.rvm/gems/xxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
(in /Users/xxxx/.rvm/gems/xxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)):
1: insert_tag renderer_for(:index)
bourbon (1.0.4) app/assets/stylesheets/css3/_background-image.scss:5
bourbon (1.0.4) app/assets/stylesheets/_bourbon.scss:9
activeadmin (0.6.0) app/assets/stylesheets/active_admin/mixins/_all.css.scss:11
activeadmin (0.6.0) app/assets/stylesheets/active_admin/_mixins.css.scss:1
active_admin_editor (1.0.5) app/assets/stylesheets/active_admin/editor.css.scss:1
sass (3.1.10) lib/sass/./sass/tree/import_node.rb:64:in `import'
sass (3.1.10) lib/sass/./sass/tree/import_node.rb:25:in `imported_file'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:147:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:27:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:47:in `visit_root'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:7:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:7:in `visit'
sass (3.1.10) lib/sass/./sass/tree/root_node.rb:20:in `render'
sass (3.1.10) lib/sass/./sass/engine.rb:300:in `_render'
sass (3.1.10) lib/sass/./sass/engine.rb:247:in `render'
sass-rails (3.2.6) lib/sass/rails/template_handlers.rb:106:in `evaluate'
tilt (1.4.1) lib/tilt/template.rb:103:in `render'
sprockets (2.1.4) lib/sprockets/context.rb:177:in `evaluate'
sprockets (2.1.4) lib/sprockets/context.rb:174:in `each'
sprockets (2.1.4) lib/sprockets/context.rb:174:in `evaluate'
sprockets (2.1.4) lib/sprockets/processed_asset.rb:12:in `initialize'
sprockets (2.1.4) lib/sprockets/base.rb:241:in `new'
sprockets (2.1.4) lib/sprockets/base.rb:241:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:262:in `circular_call_protection'
sprockets (2.1.4) lib/sprockets/base.rb:240:in `build_asset'
sprockets (2.1.4) lib/sprockets/index.rb:89:in `build_asset'
sprockets (2.1.4) lib/sprockets/caching.rb:19:in `cache_asset'
sprockets (2.1.4) lib/sprockets/index.rb:88:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:163:in `find_asset'
sprockets (2.1.4) lib/sprockets/index.rb:56:in `find_asset'
sprockets (2.1.4) lib/sprockets/bundled_asset.rb:16:in `initialize'
sprockets (2.1.4) lib/sprockets/base.rb:244:in `new'
sprockets (2.1.4) lib/sprockets/base.rb:244:in `build_asset'
sprockets (2.1.4) lib/sprockets/index.rb:89:in `build_asset'
sprockets (2.1.4) lib/sprockets/caching.rb:19:in `cache_asset'
sprockets (2.1.4) lib/sprockets/index.rb:88:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:163:in `find_asset'
sprockets (2.1.4) lib/sprockets/index.rb:56:in `find_asset'
sprockets (2.1.4) lib/sprockets/environment.rb:74:in `find_asset'
sprockets (2.1.4) lib/sprockets/base.rb:171:in `[]'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:126:in `asset_for'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:44:in `stylesheet_link_tag'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:43:in `collect'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:43:in `stylesheet_link_tag'
arbre (1.0.1) lib/arbre/element.rb:175:in `send'
arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:27:in `build_active_admin_head'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:26:in `each'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:26:in `build_active_admin_head'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `within'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:24:in `build_active_admin_head'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:9:in `build'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `___sers__tephan__rvm_gems_ruby_______p____saftzine_gems_activeadmin_______app_views_active_admin_resource_index_html_arb___381976998_2302642480'
arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `new'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `___sers__tephan__rvm_gems_ruby_______p____saftzine_gems_activeadmin_______app_views_active_admin_resource_index_html_arb___381976998_2302642480'
actionpack (3.2.5) lib/action_view/template.rb:145:in `send'
actionpack (3.2.5) lib/action_view/template.rb:145:in `render'
activesupport (3.2.5) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.5) lib/action_view/template.rb:143:in `render'
.
.
.
The active-admin.css.scss is:
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!
#import "active_admin/mixins";
#import "active_admin/base";
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// body.active_admin {
// .status_tag { background: #6090DB; }
// }
//
// Notice that Active Admin CSS rules are nested within a
// 'body.active_admin' selector to prevent conflicts with
// other pages in the app. It is best to wrap your changes in a
// namespace so they are properly recognized. You have options
// if you e.g. want different styles for different namespaces:
//
// .active_admin applies to any Active Admin namespace
// .admin_namespace applies to the admin namespace (eg: /admin)
// .other_namespace applies to a custom namespace named other (eg: /other)
//= require active_admin/editor/wysiwyg
The only place I can find linear-gradient is in
Searching 482 files for "linear-gradient"
/Users/xxxxx/.rvm/gems/xxxxx/gems/activeadmin-0.6.0/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss:
$secondary-gradient-start: #efefef !default;
$secondary-gradient-stop: #dfe1e2 !default;
#mixin gradient($start, $end){
background: $start;
background: -webkit-linear-gradient(-90deg, $start, $end);
background: -moz-linear-gradient(-90deg, $start, $end);
background: linear-gradient(-90deg, $start, $end);
// IE 6 & 7
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($start)}', endColorstr='#{ie-hex-str($end)}');
// IE 8
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($start)}', endColorstr='#{ie-hex-str($end)}');
}
#mixin primary-gradient {
#include gradient(lighten($primary-color, 5%), darken($primary-color, 7%));
border-bottom: 1px solid darken($primary-color, 11%);
}
#mixin secondary-gradient {
#include gradient($secondary-gradient-start, $secondary-gradient-stop);
}
#mixin highlight-gradient {
#include gradient(#75a1c2, #608cb4);
}
#mixin reverse-highlight-gradient {
#include gradient(#608cb4, #75a1c2);
}
#mixin no-gradient {
background: none;
// IE 6 & 7
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
// IE 8
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled=false)";
}
active_admin_editor-1.0.x/app/assets/stylesheets/active_admin/editor.css.scss starts with:
#import 'active_admin/mixins';
body form .html_editor {
.wrap {
width: 76%;
float: left;
}
.
.
.
Where am I missing something. How can I get this to work?
My guess is it is related to the removal of Bourbon or the removal of sass-rails. Re-adding one or both may resolve the issue.
Thanks to Piers C and some research on the AA GitHub I was able to find a solution to my problem.
The problem might be related to either Bourbon, SASS or the assets pipeline.
In my case I ended up
deleting #import "bourbon"; from
activeadmin-0.6.0/app/assets/stylesheets/mixins/_all.css.scss
adding a _box_shadow.css.scss mixin in the same folder and
importing it in _all.css.scss
editing the _gradient.css.scss mixin in AA
Now I have the following files:
activeadmin-0.6.0/app/assets/stylesheets/mixins/_all.css.scss
#import "active_admin/mixins/variables";
#import "active_admin/mixins/reset";
#import "active_admin/mixins/gradients";
#import "active_admin/mixins/shadows";
#import "active_admin/mixins/icons";
#import "active_admin/mixins/rounded";
#import "active_admin/mixins/buttons";
#import "active_admin/mixins/sections";
#import "active_admin/mixins/utilities";
#import "active_admin/mixins/typography";
#import "active_admin/mixins/box_shadow";
activeadmin-0.6.0/app/assets/stylesheets/mixins/_box_shadow.css.scss
#mixin box-shadow ($shadow-1,
$shadow-2: false, $shadow-3: false,
$shadow-4: false, $shadow-5: false,
$shadow-6: false, $shadow-7: false,
$shadow-8: false, $shadow-9: false)
{
$full: compact($shadow-1, $shadow-2, $shadow-3, $shadow-4,
$shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9);
-webkit-box-shadow: $full;
-moz-box-shadow: $full;
-ms-box-shadow: $full;
-o-box-shadow: $full;
box-shadow: $full;
}
activeadmin-0.6.0/app/assets/stylesheets/mixins/_gradient.css.scss
$secondary-gradient-start: #efefef !default;
$secondary-gradient-stop: #dfe1e2 !default;
#mixin gradient($start, $end) {
background-color: $start;
background-image: unquote("linear-gradient(180deg, #{$start}, #{$end})");
}
#mixin primary-gradient {
#include gradient(lighten($primary-color, 5%), darken($primary-color, 7%));
border-bottom: 1px solid darken($primary-color, 11%);
}
#mixin secondary-gradient {
#include gradient($secondary-gradient-start, $secondary-gradient-stop);
}
#mixin highlight-gradient {
#include gradient(#75a1c2, #608cb4);
}
#mixin reverse-highlight-gradient {
#include gradient(#608cb4, #75a1c2);
}
#mixin no-gradient {
background-color: none;
}
I mention step three just for completeness, since I discovered later that I did not replicate this step in production, but that everything was working nevertheless.

file to import not found or unreadable: compass/css3

I have looked at the answers below and even after running compass compile I still get the error below.
I have installed all required gems but I keep getting the error.
What would be the best way to import fonts using the SASS workflow, any guidance would be greatly appreciated.
My Config.rb file
add_import_path "bower_components/foundation/scss"
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
output_style = :compressed
My Gruntfile
/*jslint node: true */
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
options: {
includePaths: ['bower_components/foundation/scss']
},
dist: {
options: {
outputStyle: 'compressed',
sourceMap: false,
},
files: {
'css/app.css': 'sass/app.scss'
}
}
}, // sass
compass: {
dev: {
options: {
config: 'config.rb'
}
} // dev
}, //compass
watch: {
options: {
livereload: true,
dateFormat: function(time) {
grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString());
grunt.log.writeln('Waiting for more changes...');
} //date format function
}, //options
scripts: {
files: ['*.js']
}, // scripts
//Live Reload of SASS
sass: {
files: 'sass/**/*.scss',
tasks: ['sass']
}, //sass
css: {
files: ['sass/*.scss'],
tasks: ['compass']
},
html: {
files: ['*.html']
}
} //watch
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('build', ['sass', 'compass']);
grunt.registerTask('default', ['build', 'watch']);
}
My Gems
actionpack (4.2.3)
actionview (4.2.3)
activesupport (4.2.3)
bigdecimal (1.2.0)
builder (3.2.2)
bundler (1.10.5)
CFPropertyList (2.2.8)
chunky_png (1.3.4, 1.3.3)
compass (1.0.3)
compass-core (1.0.3)
compass-import-once (1.0.5)
compass-rails (2.0.4)
erubis (2.7.0)
ffi (1.9.10)
foundation (1.0.4)
fssm (0.2.10)
hike (1.2.3)
i18n (0.7.0)
io-console (0.4.2)
json (1.7.7)
libxml-ruby (2.6.0)
loofah (2.0.2)
mini_portile (0.6.2)
minitest (5.7.0, 4.3.2)
multi_json (1.11.2)
nokogiri (1.6.6.2)
psych (2.0.0)
rack (1.6.4)
rack-test (0.6.3)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.6)
rails-html-sanitizer (1.0.2)
railties (4.2.3)
rake (0.9.6)
rb-fsevent (0.9.5)
rb-inotify (0.9.5)
rdoc (4.0.0)
sass (3.4.16)
sass-rails (5.0.1)
sprockets (2.12.4)
sprockets-rails (2.3.2)
sqlite3 (1.3.7)
susy (2.2.2)
test-unit (2.0.0.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tzinfo (1.2.2)

Padrino content_for rendering string instead of HTML

I have a Sinatra app and am using Padrino. When I use the content_for helper to render content within a layout it returns it as a string instead of html.
app.rb
class CateringApp < Sinatra::Application
register Padrino::Helpers
end
layout.erb
<div id="page-wrapper">
<%= flash[:notice] %>
<%= content_for?(:main_table) ? yield_content(:main_table) : yield %>
</div>
category.erb
<% content_for :main_table do %>
<div id="name" class="row">
"IM ALIVE"
</div>
<% end %>
and the result I'm getting on my browser is the literal string
<div id="name" class="row">
"IM ALIVE"
</div>
app.rb
require 'dotenv'
Dotenv.load
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/reloader'
require 'sinatra/flash'
require 'sinatra/assetpack'
require 'padrino-helpers'
class CateringApp < Sinatra::Application
enable :protect_from_csrf
use Rack::Session::Cookie, :secret => ENV['SESSION_SECRET']
register Padrino::Helpers
register Sinatra::AssetPack
end
# require all config files
Dir["./config/*.rb"].each {|file| require file }
require './auth'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
activemodel (4.1.6)
activesupport (= 4.1.6)
builder (~> 3.1)
activerecord (4.1.6)
activemodel (= 4.1.6)
activesupport (= 4.1.6)
arel (~> 5.0.0)
activesupport (4.1.6)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
backports (3.6.0)
builder (3.2.2)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
dotenv (0.11.1)
dotenv-deployment (~> 0.0.2)
dotenv-deployment (0.0.2)
excon (0.39.6)
fog (1.23.0)
fog-brightbox
fog-core (~> 1.23)
fog-json
fog-softlayer
ipaddress (~> 0.5)
nokogiri (~> 1.5, >= 1.5.11)
fog-brightbox (0.5.1)
fog-core (~> 1.22)
fog-json
inflecto
fog-core (1.24.0)
builder
excon (~> 0.38)
formatador (~> 0.2)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-json (1.0.0)
multi_json (~> 1.0)
fog-softlayer (0.3.19)
fog-core
fog-json
formatador (0.2.5)
i18n (0.6.11)
inflecto (0.0.2)
ipaddress (0.8.0)
jsmin (1.0.1)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.6.0)
minitest (5.4.1)
multi_json (1.10.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
padrino-helpers (0.12.3)
i18n (~> 0.6, >= 0.6.7)
padrino-support (= 0.12.3)
tilt (~> 1.4.1)
padrino-support (0.12.3)
activesupport (>= 3.1)
pg (0.17.1)
polyglot (0.3.5)
pony (1.11)
mail (>= 2.0)
rack (1.5.2)
rack-protection (1.5.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sinatra-activerecord (2.0.2)
activerecord (>= 3.2)
sinatra (~> 1.0)
sinatra-assetpack (0.3.3)
jsmin
rack-test
sinatra
tilt (>= 1.3.0, < 2.0)
sinatra-contrib (1.4.2)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
sinatra-flash (0.3.0)
sinatra (>= 1.0.0)
sinatra-reloader (1.0)
sinatra-contrib
thread_safe (0.3.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
activerecord
carrierwave
dotenv
fog
padrino-helpers
pg
pony
sinatra
sinatra-activerecord
sinatra-assetpack
sinatra-flash
sinatra-reloader
Include gem 'erubis' in your Gemfile.
Padrino::Rendering can only be activated if the corresponding gem (erubis, haml or slim) is included into the bundle and visible at the moment of requiring 'padrino-helpers'.

Unable to find matching line from backtrace in ruby 2.0, rspec 3.0

I got this error when running a feature spec using rspec 3.0, ruby 2.0.0p195 on Windows in Rails 4.0. Reading on Googles, I find that a fix was to use a specific version in rpsec 2.0 but nothing past that version. I thought I would have been long past that issue. Like others, I find that when I manually act out the steps of the feature, everything works as expected. There is no indicator of what line of the spec fails. Where should I look in Google to get past this issue? Or have I made a goof somewhere?
gemfile.lock
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-rails (3.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
Fails here: _score_form.html.erb
<%= simple_form_for [#site, #inspection, score] do |f| %>
<%= f.input :note %>
<%= f.button :submit, submit_text %>
<% end %>
<a class="close-reveal-modal">×</a>
note_feature_spec.rb
require 'spec_helper'
feature "notes", js: true do
background do
#surveys = ["Loss", "Solutions"]
#manager = FactoryGirl.create(:manager)
#site = FactoryGirl.create(:site)
#user = FactoryGirl.create(:user, site_id: #site.id)
#survey = FactoryGirl.create(:survey, name: "#{#surveys[1]}", user_id: #manager.id)
#item_1 = FactoryGirl.create(:item, name: "item 1", survey_id: #survey.id, category: "Regular", sub_category:
'DEC')
#variance = FactoryGirl.create(:cash_variance)
end
scenario "appear when saved with a score" do
visit root_path
click_link 'Login'
fill_in 'Email', with: #manager.email
fill_in 'Password', with: #manager.password
click_button 'Log in'
click_link ("#{#site.name}" + " #{#site.site_type}")
click_link 'New Inspection'
select("#{#survey.name}")
click_button 'Start inspection'
score = Score.where(inspection_id: Inspection.last.id, item_id: #item_1.id).first
expect(page).to have_content("#item.name")
expect(page).to have_css("note-act#{#score.id}")
end
end
relevant portion of scores_controller.rb
class ScoresController < ApplicationController
def update
#site = Site.find(params[:site_id])
#inspection = #site.inspections.find(params[:inspection_id])
#score = #inspection.scores.find(params[:id])
respond_to do |format|
if #score.update_attributes(score_params)
format.html {redirect_to edit_site_inspection_path(#site,#inspection), notice: 'Score was updated'}
format.json {head :no_content}
format.js
else
format.html { render action: 'edit'}
format.json { render json: #score.errors, status: :unprocessable_entity }
end
end
end
Top of error message:
1) notes it appears when saved with a score
Failure/Error: Unable to find matching line from backtrace
ActionView::Template::Error:
undefined method `note' for #<Score:0x8acdb60>
# ./app/views/inspections/_score_form.html.erb:2:in `block in _app_views_inspections__score_form_html_erb__524083191_68481552'
# ./app/views/inspections/_score_form.html.erb:1:in `_app_views_inspections __score_form_html_erb__524083191_68481552'
# ./app/views/inspections/_regular.html.erb:13:in `_app_views_inspections__regular_html_erb__743764807_72723960'
# ./app/views/inspections/_clean_scores.html.erb:17:in `block (3 levels) in _app_views_inspections__clean_scores_html_erb___604997166_72361188'
# ./app/views/inspections/_clean_scores.html.erb:15:in `each'
# ./app/views/inspections/_clean_scores.html.erb:15:in `block (2 levels) in
It turns out there is a migration missing, so it is as I suspected: a goof.

Can't use facebook to authenticate: undefined method 'web_server' for OAuth2?

Trying to let users sign in / sign up with Twitter and Facebook. Twitter works no problem but the strategy is different for Facebook.
undefined method `web_server' for #<OAuth2::Client:0x00000005211d58>
Trace shows
oa-oauth (0.0.1) lib/omniauth/strategies/oauth2.rb:18:in `request_phase'
oa-oauth (0.0.1) lib/omniauth/strategies/facebook.rb:28:in `request_phase'
oa-core (0.0.5) lib/omniauth/strategy.rb:25:in `call!'
oa-core (0.0.5) lib/omniauth/strategy.rb:19:in `call'
oa-core (0.0.5) lib/omniauth/builder.rb:22:in `call'
warden (1.0.5) lib/warden/manager.rb:35:in `block in call'
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
warden (1.0.5) lib/warden/manager.rb:34:in `call'
Anybody else experienced this?
ps. I'm using the following gems:
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'oauth2'
I'm not using the full omniauth gem as its addressable dependencies conflict with other gems.
I ran into the same problem when trying to use facebook_oauth (https://github.com/moomerman/facebook_oauth) on my rails app. After spending an hour or so trying to change its code, i realized it might be easier just to use oauth2 directly. I solved the problem and now there's no need for that intermediate library. Here's how:
In Gemfile add
gem 'oauth2'
Then run
bundle update
Then, in your login_via_facebook method you either construct the dialog uri manually or use the oauth client something along these lines:
oauth_client = OAuth2::Client.new(APPLICATION_ID, APPLICATION_SECRET, {
:authorize_url => 'https://www.facebook.com/dialog/oauth'
})
redirect_to oauth_client.authorize_url({
:client_id => APPLICATION_ID,
:redirect_uri => YOUR_REDIRECT_URL
})
If you need to request additional permissions, specify scope param in the authorize_url call:
redirect_to oauth_client.authorize_url({
:client_id => APPLICATION_ID,
:redirect_uri => YOUR_REDIRECT_URL,
:scope => 'offline_access,email'
})
Then, in the method that handles YOUR_REDIRECT_URL (i call mine login_via_facebook_callback), do something like this:
oauth_client = OAuth2::Client.new(APPLICATION_ID, APPLICATION_SECRET, {
:site => 'https://graph.facebook.com',
:token_url => '/oauth/access_token'
})
begin
access_token = oauth_client.get_token({
:client_id => APPLICATION_ID,
:client_secret => APPLICATION_SECRET,
:redirect_uri => YOUR_REDIRECT_URL,
:code => params[:code],
:parse => :query
})
access_token.options[:mode] = :query
access_token.options[:param_name] = :access_token
facebook_user_info = access_token.get('/me', {:parse => :json}).parsed
rescue Error => e
# You will need this error during development to make progress :)
#logger.error(e)
end
Now facebook_user_info has the basic user info!
I had a similar issue, you should try two things:
I also had conflicting gem issues/dependencies issues and resolved them by adding this in my gemfile:
gem 'omniauth', :git => 'git://github.com/intridea/omniauth.git'
Try using a rails application template which works remarkably well for starting a Twitter/Facebook app in no time, run this command in your terminal:
rails new APP_NAME -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-omniauth-template.rb -T
You can read more about it here:
https://github.com/RailsApps/rails3-mongoid-omniauth/wiki/Tutorial
here i came across an example app that demonstrates the use of omniauth along with authlogic
https://github.com/madhums/omniauth-authlogic-demo
hope it helps

Resources