我目前正在使用考拉,所有似乎都在工作,但当试图使用以下来获得某些帖子上的喜欢我似乎得到的是项目数组
应用程序助手中的代码
def facebook
@facebook ||= Koala::Facebook::API.new(current_user.oauth_token)
block_given? ? yield(@facebook) : @facebook
rescue Koala::Facebook::APIError
logger.info e.to_s
nil
end
def likes_count obj
facebook.get_object(obj, :fields => "likes.summary(true)")
end
Run Code Online (Sandbox Code Playgroud)
视图中的代码
=likes_count(feed['id'])
Run Code Online (Sandbox Code Playgroud)
结果返回
{"id"=>"846011512095715", "updated_time"=>"2014-06-22T11:11:45+0000", "likes"=>{"data"=>[{"id"=>"10152444475716893", "name"=>"Tahlia Fulton"}, {"id"=>"10152240895519022", "name"=>"Tim Raftery"}, {"id"=>"481256765338477", "name"=>"Gabby Taylor"}, {"id"=>"664803753573900", "name"=>"Harriet Ochsenbein"}, {"id"=>"10152453604228810", "name"=>"Kelly Jenkinson"}, {"id"=>"10152145864189249", "name"=>"David Glazzard"}, {"id"=>"10203193488711772", "name"=>"Bianca Love"}, {"id"=>"10152567265688833", "name"=>"Clare Duncan"}, {"id"=>"105513176145556", "name"=>"Frankston Hockey Club"}], "paging"=>{"cursors"=>{"after"=>"MTA1NTEzMTc2MTQ1NTU2", "before"=>"MTAxNTI0NDQ0NzU3MTY4OTM="}}, "summary"=>{"total_count"=>9}}}
Run Code Online (Sandbox Code Playgroud) 我试图在我的苗条模板的开头添加一个空间,由于链接我不得不打破文本,我不能为我的生活工作这一个
.mdl-cell.mdl-cell--4-col-phone.mdl-cell--8-col-tablet.mdl-cell--12-col-desktop
| Don't have an account?
= link_to 'Create one here.', sign_up_path
Run Code Online (Sandbox Code Playgroud) 我试图让zurb基础图标字体在我的rails项目中工作,虽然它们似乎没有正常工作
general_foundicons.css.sass
/* font-face
@font-face
font-family: "GeneralFoundicons"
src: font-url("general_foundicons.eot")
src: font-url("general_foundicons.eot?#iefix") format("embedded-opentype"), font-url("general_foundicons.woff") format("woff"), font-url("general_foundicons.ttf") format("truetype"), font-url("general_foundicons.svg#GeneralFoundicons") format("svg")
font-weight: normal
font-style: normal
Run Code Online (Sandbox Code Playgroud)
我有这些文件app/assets/fonts虽然字体似乎没有加载
我试图在Yosemite上通过RVM安装Ruby on Rails.但是,当我尝试运行"捆绑安装"时,一切似乎都有效,我发现有关Nokogiri的错误:
pauls-air:~ paulmcguane$ gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
Run Code Online (Sandbox Code Playgroud)
错误消息是:
/Users/paulmcguane/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of …Run Code Online (Sandbox Code Playgroud) 我有一个供应商名称和电子邮件的基本表单设置.我想将我的地址属性嵌套到这个表单中,但我一直得到以下错误
未允许的参数:地址
class Supplier < ActiveRecord::Base
has_many :addresses, dependent: :destroy, as: :addressable
accepts_nested_attributes_for :addresses
end
class Address < ActiveRecord::Base
belongs_to :addressable, polymorphic: true
belongs_to :supplier
end
class SuppliersController < ApplicationController
def allowed_params
params.require(:supplier).permit(:name, :email, {:address_attributes => [:first_name, :last_name, :address1, :address2, :city, :zip_code, :country_id]})
end
end
Run Code Online (Sandbox Code Playgroud)
供应商表格
%fieldset#admin-supplier-names.span-12
%label Name
= form.text_field :name
%label Email
= form.text_field :email
= form.fields_for :address do |address_fields|
%li= address_fields.text_field :first_name, placeholder: :first_name.upcase, value: current_user.first_name
%li= address_fields.text_field :last_name, placeholder: :last_name, value: current_user.last_name
%li= address_fields.text_field :address1, placeholder: …Run Code Online (Sandbox Code Playgroud) 我试图了解如何使用router-flux并且具有类似于具有多个故事板的多个场景/子场景,以便我可以为用户注册过程创建场景,然后一次用户注册的场景并登录.
目前我这样做但是没有给我预期的结果
class NavigationRouter extends Component {
render () {
return (
<Router>
<Scene key='drawer' component={NavigationDrawer} open={false}>
<Scene key='root' tabs={true}>
<Scene key='account' hideNavBar={true} >
<Scene initial key='Login' component={Login} title='Login' />
<Scene key='SignUp' component={SignUp} title='SignUp' />
<Scene key='Account' component={Account} title='Account' />
<Scene key='Venue' component={Venue} title='Venue' />
</Scene>
<Scene key='auth' renderLeftButton={NavItems.hamburgerButton} navigationBarStyle={Styles.navBar} titleStyle={Styles.title} leftButtonIconStyle={Styles.leftButton} rightButtonTextStyle={Styles.rightButton} >
<Scene key='MenuItems' component={MenuItems} title='Your Menu' />
<Scene key='Orders' component={Orders} title='Orders' />
</Scene>
</Scene>
</Scene>
</Router>
)
}
}
Run Code Online (Sandbox Code Playgroud)
登录/注册过程的第一部分不应显示导航栏并允许用户返回上一步.
第二部分应允许登录用户访问导航栏和侧面绘制其中定义的项目
我正在尝试弄清楚如何将以下数据放入数据表中,但我真的很挣扎,因为它不断重复标题
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class PlayerList extends StatefulWidget {
@override
_PlayerListState createState() => new _PlayerListState();
}
class _PlayerListState extends State<PlayerList> {
StreamController<List<Map<String, dynamic>>> _postsController;
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
List<Map<String, dynamic>> _list = List();
ScrollController _scrollController = new ScrollController();
int count = 0;
var url = '';
bool fetching = false, endReached = false;
List data;
Future<List<dynamic>> fetchPlayer() async {
url =
'https://supercoach.heraldsun.com.au/2020/api/afl/classic/v1/players-cf?embed=notes%2Codds%2Cplayer_stats%2Cpositions';
final response = await http.get(url);
if (response.statusCode …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用现在使用zepto框架的emberjs和foundation 4,但是只要我将emberjs include添加到我的application.js中,基础代码就会停止工作.包含的顺序有问题吗?
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require events
//= require foundation
//= require rails.validations
//= require rails
//= require gmaps4rails/gmaps4rails.base
//= require gmaps4rails/gmaps4rails.googlemaps
//= require handlebars
//= require ember
//= require ember-data
//= require teammngt
//= require_self
TeamMngt = Ember.Application.create();
$(document).foundation();
Run Code Online (Sandbox Code Playgroud) 我使用这个Pundit宝石相当新,但似乎无法理解政策系统.从我读过的所有内容看起来都是正确的,尽管我仍然收到错误
应用控制器
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery
before_filter :authenticate_person!
# Verify that controller actions are authorized. Optional, but good.
after_filter :verify_authorized, except: :index
after_filter :verify_policy_scoped, only: :index
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def pundit_user
Person.find_by_id(current_person)
end
def user_not_authorized
flash[:alert] = "You are not authorized to perform this action."
# redirect_to(request.referrer || root_path)
end
end
Run Code Online (Sandbox Code Playgroud)
申请政策
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
raise Pundit::NotAuthorizedError, "must be logged in" unless user
@user = user
@record = record
end …Run Code Online (Sandbox Code Playgroud) 我试图只根据传递的不同信息显示表中的某些记录,如果没有满足任何要求,它会重定向到主页.代码全部正常运行,只想看看其他人如何解决这个问题
if current_user.admin?
@schedules = Schedule.all
elsif current_user.team_id?
@schedules = Schedule.find_all_by_team_id(current_user[:team_id])
else
redirect_to root_path, :status => 301, :alert => "Please contact your club administrator to be assigned to a team."
return
end
Run Code Online (Sandbox Code Playgroud) 看看如何在用jquery动态添加表格后突出显示表格行我的代码似乎是添加了没有问题的行,但它没有突出显示正确的行
jQuery的
$('#opponents tr:last').after('<tr><td>data</td><td>more data</td></tr>').effect("highlight", {}, 3000);
Run Code Online (Sandbox Code Playgroud)
HAML /表
%table.twelve#opponents
%thead
%tr
%th Name
%th Manager
%tbody
- @opponents.each do |opponent|
%tr
%td= opponent.name
%td.span1
- if can? :update, @opponent
.btn-group
%button.btn.dropdown-toggle{"data-toggle" => "dropdown"}
%i.icon-pencil
Manage
%span.caret
%ul.dropdown-menu
%li= link_to "Edit #{opponent.name}", "#modalOpponent"
-if can? :manage, @opponent
%li.divider
%li= link_to "Delete #{opponent.name}", opponent, :method => :delete, :remote => :true, :confirm => true
Run Code Online (Sandbox Code Playgroud) 我之前没有经历过这个,但是自从我的rails网站移到Heroku后,每当我试图触发Devise发送电子邮件时,我都收到以下消息
Started POST "/members/forgot-password" for 127.0.0.1 at 2013-02-24 00:02:27 +1100
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"?", "authenticity_token"=>"9G1P34ddbq2TN7SkmFuCet5d7fPMvWdSSpIaGqSZW9g=", "user"=>{"email"=>"paul.mcguane@*****"}, "commit"=>"Recover password"}
User Load (3.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'paul.mcguane@me.com' LIMIT 1
Completed 500 Internal Server Error in 31ms
ArgumentError - wrong number of arguments (2 for 1):
app/mailers/devise/mailer.rb:8:in `reset_password_instructions'
Run Code Online (Sandbox Code Playgroud)
mailer.rb
class Devise::Mailer < ::ActionMailer::Base
include Devise::Mailers::Helpers
def confirmation_instructions(record)
devise_mail(record, :confirmation_instructions)
end
def reset_password_instructions(record)
devise_mail(record, :reset_password_instructions)
end
def unlock_instructions(record)
devise_mail(record, :unlock_instructions)
end
end
Run Code Online (Sandbox Code Playgroud) 我试图获取我刚刚在firebase上推送的最后一个节点的密钥,但我的代码仍然出错
constructor (props) {
super(props)
this.cartFirebase = firebaseApp.database().ref('carts')
}
componentDidMount () {
this.cartFirebase.child(DeviceInfo.getUniqueID() + '/items').push({
item: this.props.data.name,
qty: 1
})
this.cartFirebase.limit(1).on('child_added', function(snapshot) {
console.log(snapshot)
})
}
Run Code Online (Sandbox Code Playgroud)
devise ×2
react-native ×2
actionmailer ×1
dart ×1
datatables ×1
ember.js ×1
firebase ×1
flutter ×1
forms ×1
haml ×1
homebrew ×1
icon-fonts ×1
javascript ×1
jquery ×1
koala ×1
navigator ×1
nested-forms ×1
nokogiri ×1
osx-yosemite ×1
pundit ×1
slim-lang ×1
zepto ×1