我有Microsoft Visual Studio Express 2013 for Web,版本12.0.30501.00更新2.我有一个包含2个项目的解决方案,一个是web api,第二个是用于视图的MVC项目.我创建了一个简单的web api返回httpresponsemessage,我可以进入fiddler,我会看到json响应.但是在我尝试通过ajax调用的第二个项目中,我收到了跨域错误.
我试图遵循的解决方案是http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api.但是,当Install-Package Microsoft.AspNet.WebApi.Cors -pre -project WebService在控制台管理器中安装时,我收到了一个错误,所以我使用了这一行.Install-Package Microsoft.AspNet.WebApi.Cors然后我尝试下一步就是config.EnableCors();它的状态
'System.Web.Http.HttpConfiguration' does not contain a definition for 'EnableCors' and no extension method 'EnableCors' accepting a first argument of type 'System.Web.Http.HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我不知道后来会发生什么,我也尝试添加,using System.Web.Http.Cors;但声明命名空间不存在.这个视觉工作室是在大约3周前下载的,我觉得这个功能不应该很难安装,因为它完全支持,有什么我缺少的东西?
我想知道如何为不同用户的现有数据库添加设计.在这里,我已经有一个客户模型定义,我想改变以允许设计工作.
我已经创建了一个新的迁移并插入了代码
class AddDeviseToCustomer < ActiveRecord::Migration
def change
change_table :customers do |t|
#t.database_authenticatable
t.string :encrypted_password, :null => false, :default => '', :limit => 128
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.token_authenticatable
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)
据此,它应该工作.https://github.com/plataformatec/devise/wiki/How-To:-change-an-already-existing-table-to-add-devise-required-columns.但是当运行rake db:migrate时,我得到以下内容
undefined method `confirmable' for #<ActiveRecord::ConnectionAdapters::Table:0x9286a28>
Run Code Online (Sandbox Code Playgroud)
我运行了以下行
rails g devise:install
Run Code Online (Sandbox Code Playgroud)
任何理由设计都不会认出来,我是否需要做一些事情来说客户是一个设计?提前致谢
我正在尝试在Windows上安装ImageMagick.我做的是安装Windows RailsInstaller创建我的版本,现在我需要使用ImageMagick但由于某种原因它不起作用.
我拿了二进制源代码并从这个页面安装并运行它,但似乎没有做到这一点http://www.imagemagick.org/script/binary-releases.php#windows
我也尝试以下http://www.youtube.com/watch?v=gEWAVlNCKhg但它不起作用
对于第一个例子在cmd中,我所要做的就是以下命令让我理解为使它在我所能得到的工作
C:\Sites\case>convert wizard: wizard.jpg
Invalid Parameter - wizard.jpg
C:\Sites\case>convert wizard.jpg
Invalid drive specification.
C:\Sites\case>convert logo: logo.gif
Invalid Parameter - logo.gif
C:\Sites\case>$ convert logo: logo.gif
'$' is not recognized as an internal or external command,
operable program or batch file.
C:\Sites\case>
Run Code Online (Sandbox Code Playgroud)
然后我看到了这个.从https://github.com/rmagick/rmagick说它包括rmagick然后我运行bundle并得到这个
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** …Run Code Online (Sandbox Code Playgroud) 我不确定如何为我的搜索功能提供自动填充表单.
<%= form_tag "/search", :method => "get" do %>
<%= text_field_tag :query, params[:query] %>
<%= image_submit_tag "site/blankimg.png", :name => nil %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我有一个以下控制器,它有一个自定义的动作
def query
@users= Search.user(params[:query])
@article= Search.article(params[:query])
end
Run Code Online (Sandbox Code Playgroud)
该模型如下:
def self.user(search)
if search
User.find(:all, :conditions => ['first_name LIKE ?', "%#{search}%"])
else
User.find(:all)
end
end
def self.article(search)
if search
Article.find(:all, :conditions => ['title LIKE ?', "%#{search}%"])
else
Article.find(:all)
end
end
Run Code Online (Sandbox Code Playgroud)
现在这项工作非常适合搜索但是它,我希望它能告诉我结果我正在编写它,并且我不能使用jquery自动完成,因为它是两个对象.
我正在尝试重新学习ASP.NET并构建一些应用程序,但是教程似乎正在运行短路.
我理解ASP.NET现在具有内置成员资格,允许用户创建和编辑,登录用户.但是,有没有办法让我创建一个用户控制器.从我所读到的,它是一个很大的不,因为它可能与AccountController冲突.也许这是错的,但我想先确定一下.
另外我理解我可以在控制器(动作或类)中使用[授权]一词来限制对用户的访问.但是,如果我提供[授权(角色="管理员")]如何为用户定义角色?是否存在已提供此功能的成员资格中的字段,或者我是否需要提供第二个nuget软件包.如果是来自用户的字段,它如何知道角色是用户表中的值?
我想知道是否有一个功能或方法从jquery/javascript一次在线选择.问题是它必须是<pre></pre>标签内的元素.
代码看起来像这样
Course Grade Mark Science 70 50
我想保留这个空间,我相信一次选择一行会很棒.
在这里看看我有什么,不多
var test = $('pre').html();
Run Code Online (Sandbox Code Playgroud)
谢谢.对于任何输入.
我试图同时创建两个对象,但由于某种原因,我的第二个对象的字段是空白的.
模型是:
Users: id, name, last, email, password ...
Locations: address, longitude, latitude.
Run Code Online (Sandbox Code Playgroud)
关系如此:
User has_many location
Location belongs_to users
Run Code Online (Sandbox Code Playgroud)
事件控制器创建方法:
def create
@event = current_users.events.build(params[:event])
@location = @event.locations.build(params[:location])
@location.longitude = params[:longitude]
@location.latitude = params[:latitude]
respond_to do |format|
if @location.save
@location.longitude = params[:longitude]
@location.latitude = params[:latitude]
if @location.save
if @event.save
format.html { redirect_to @event, notice: 'Event was successfully created.' }
format.json { render json: @event, status: :created, location: @event }
else
format.html { render action: "new" }
format.json { render …Run Code Online (Sandbox Code Playgroud) 如何在我的自定义会话控制器上确定该用户是第一次登录,我希望能够创建会话并重定向到welcome#index第一次将其重定向到root_url.
我拥有的代码如下
class MysessionsController < Devise::SessionsController
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_in_path_for(resource)
end
protected
def after_sign_up_path_for(resource)
"http://google.com"
end
end
Run Code Online (Sandbox Code Playgroud)
我知道我需要自定义after_sign_up_path_for(resource)我想要的但我无法确定如何确定用户之前是否登录过设计
前一段时间用语言给我一个堆栈错误太深的错误.我在这里怎么称呼它.
<%= link_to time_ago_in_words(f.created_at), f %>
Run Code Online (Sandbox Code Playgroud)
这就是我在article.helper中所做的
def time_ago_in_words(time_str)
time = time_str.to_time + (-Time.zone_offset(Time.now.zone))
"happened #{time_ago_in_words(time)} ago"
end
Run Code Online (Sandbox Code Playgroud)
我不能重新定义time_ago_in_words吗?因为我也尝试了以下,它给了我同样的错误
<%= link_to ctime_ago_in_words(f.created_at), f %>
def ctime_ago_in_words(time_str)
time = time_str.to_time + (-Time.zone_offset(Time.now.zone))
"happened #{ctime_ago_in_words(time)} ago"
end
Run Code Online (Sandbox Code Playgroud) 我正在尝试安装imagemagick和rmagick所以我可以用rails运行carrierwave gem.我和Dreamhost在VPS上.宝石的服务器和安装不是我的强项,我能够使用以下命令在我的localmachine上安装这些宝石
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo gem install rmagick
Run Code Online (Sandbox Code Playgroud)
但是在VPS服务器上有点不同,但通过这样做它只是不起作用.在dreamhost上安装carrierwave的正确方法是什么.谢谢!
我试图选择一个输入框,但因为我可能有多个输入,我试图限制我选择的那个.这是我的jquery代码选择输入但由于某种原因它不起作用.我做错了吗?文档准备好后即可执行此操作.
if ( $("input[name='RETURN.URL'][value='http://link.com?TYPE=P&PID=ST-L09F166&CONSTITUENCY=WBST']").length > 0 )
{
alert("Transcript report");
}
else
{
alert("Not Transcript Report");
}
Run Code Online (Sandbox Code Playgroud)
这里是html
<input type="hidden" name="RETURN.URL" value="http://link.com?TYPE=P&PID=ST-L09F166&CONSTITUENCY=WBST">
<input type="hidden" name="SUBMIT_OPTIONS" value="">
Run Code Online (Sandbox Code Playgroud) ruby ×7
asp.net ×2
devise ×2
imagemagick ×2
javascript ×2
jquery ×2
asp.net-mvc ×1
autocomplete ×1
c# ×1
carrierwave ×1
dreamhost ×1
geocoding ×1
rmagick ×1