维基百科说:
MVC为数据库,用户和数据处理组件提供前端和后端.将软件系统分离为前端和后端简化了开发并分离了维护.
我仍然没有看到模型 - 视图 - 控制器原理与前端和后端的概念之间的联系.可以将具有数据库访问权限的模型视为后端,将视图视为前端吗?
我想在视图中查看来自不同数据库表的数据,如下图所示:
我熟悉的HTML标签<table>
,<td>
和<tr>
,但我在与一列多个查询的麻烦.
<table>
<tr>
<th>Skills </th>
<th>Expected-qualifications</th>
<th>Current-qualifications</th>
</tr>
<% @employee.position.skills.each do |skill| %><% @employee.position.expected_qualifications.each do |expected_qualification| %><% @employee.current_qualifications.each do |current_qualification| %>
<tr>
<td><%= skill.kategorien %></td>
<td><%= expected_qualification.sollqualifikation %></td>
<td><%= current_qualification.istqualifikation %></td>
</tr>
<% end %><% end %><% end %>
</table>
Run Code Online (Sandbox Code Playgroud)
此代码如下所示:
如您所见,技能,预期资格和当前资格重复.
我的问题:如何在表格中排序代码,以便它看起来像我想要的那样?
我们正在使用jQuery Mobile的框架来构建基于HTML5的iPad应用程序的图形界面.因为我们正在为iPad创建一个应用程序,我们基本上需要像ipad一样的典型分屏:左侧的窄边栏和右侧的主要内容:
现在我的问题是:我正在搜索创建这个分割屏幕的代码,我在jquerymobile文档中找不到任何内容 - 我是否想念它或者我不理解它?如果本网站上不存在分屏的代码,我在哪里可以找到相关的内容?
因为我没有发现任何与我需要的相关的东西,所以我尝试了另一种方法来获得这个分屏.所以我在css样式表中使用块:
解释:在jQuerymobile文档中,我找到了一个名为"content formatting> layout grid(column)"的类别(http://jquerymobile.com/demos/1.0b1/#/demos/1.0b1/docs/content/content -grids.html)所以我考虑创建两个块来制作分割屏幕.但我不需要50/50的分屏,但更需要20/80或30/70.我试着把它改成我的样式表:
.ui-grid-x { overflow: hidden; }
.ui-block-x, .ui-block-y { margin: 0; padding: 0; border: 0; float: left; min-height:1px;}
/* grid a: 20/80 */
.ui-grid-x .ui-block-x { width: 20%; }
.ui-grid-x .ui-block-y { width: 80%; }
.ui-grid-x .ui-block-x { clear: left; }
Run Code Online (Sandbox Code Playgroud)
原来是:
.ui-grid-a, .ui-grid-b, .ui-grid-c, .ui-grid-d { overflow: hidden; }
.ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d, .ui-block-e { margin: 0; padding: 0; …
Run Code Online (Sandbox Code Playgroud) 我想创建一个新动作,我称之为"showemployees".这就是我已经做过的事情:
- >在控制器中:
def showemployees
end
Run Code Online (Sandbox Code Playgroud)
- >创建app/views/employees/showemployees.html.erb
- >在config/routes中
match "/employees/showemployees" => "employees#showemployees"
我认为这足以通过localhost:3000/employees/showemployees打开showemployees.html.erb,但似乎Rails仍然通过show action(来自资源:employees)进行路由,并且不接受showemployees-action,因为它告诉我
ActiveRecord::RecordNotFound in EmployeesController#show
Couldn't find Employee with ID=showemployees
Run Code Online (Sandbox Code Playgroud)
我需要改变什么才能让Rails接受showemployees-action?
我的路线的源代码:
System::Application.routes.draw do
match "/employees/showemployees" => "employees#showemployees" #für showemployees.html.erb
root :to => "employees#index"
resources :course_to_dos
resources :current_qualifications
resources :expected_qualifications
resources :skills
resources :employees
resources :positions
resources :admin
end
Run Code Online (Sandbox Code Playgroud) 我只想要一个包含项目的静态表视图.我使用Xcode 4.2和storyboard来完成这项任务.所以我用tableViewController(子类UITableViewController)创建了一个TableView.我将内容定义为"静态单元格"和样式"分组".
在那之后,我把一些标签和所有那些我想要的对象放在那些单元格中.我在tableViewController中创建了Outlets:
#import <UIKit/UIKit.h>
@interface tableviewcontroller : UITableViewController
@property (weak, nonatomic) IBOutlet UILabel *label1;
@property (weak, nonatomic) IBOutlet UILabel *label2;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segmented;
@property (weak, nonatomic) IBOutlet UIImageView *imageview;
@property (weak, nonatomic) IBOutlet UITextView *text;
@end
Run Code Online (Sandbox Code Playgroud)
在细胞标签中加入一些内容:
- (void)viewDidLoad
{
[super viewDidLoad];
self.label1.text = @"This is a title";
self.label2.text = @"Annika";
self.imageview.image = [UIImage imageNamed: @"picture.jpg"];
}
Run Code Online (Sandbox Code Playgroud)
在构建和运行之后,它没有向我显示任何元素......我做错了什么?
左:在故事板中,右:在模拟器中.
我面临一个很小的问题.在我的view.html.erb中,我使用的是德语变音符号(ä,ö,ü..).当然它不起作用,在这样的html.erb中写äöü,我需要编写普通的HTML-umlauts-codes(ü
),以便在浏览器中查看变音符号.这工作得很好,但是它没有在链接名称中工作,如下图所示:http://img7.imagebanana.com/img/540vnz2y/umlaut.PNG
这是我现在使用的代码:
<p> <%= link_to "zurÜck", :controller => "employees", :action => "index" %>
有人知道如何管理它我也可以在链接名称中使用变音符号吗?
我正在寻找一些想法如何让星星在这个例子中看起来像:
现在,我有一张桌子上有一个黑色星柱和一个灰色星柱.(在"Hüllenkontrolle"中,例如2个黑色星的"2"和4个灰色星星的"4").所以我考虑了一些显示另一张图片的内容,具体取决于数据库中的数字(1 = 1星,2 = 2星,3 = 3星,4 = 4星...)
我不知道在互联网上搜索什么或者如何意识到不会看到数字而是一些明星.有谁知道如何实现这个?
有关我的数据库模型的一些信息:http://img6.imagebanana.com/img/kwenevyz/beziehungen.png
<%= expected_qualification.qualificationstars %> <% @employee.position.expected_qualifications.each do |expected_qualification| %>
<%= expected_qualification.qualificationstars %> <% @employee.position.expected_qualifications.each do |expected_qualification| %>
<% @employee.position.expected_qualifications.each do |expected_qualification| %>
<%= expected_qualification.qualificationstars %>
<%end%>
一些好消息!这似乎有效
<% @employee.position.skills.zip(@employee.position.expected_qualifications, @employee.current_qualifications).each do |skill, expected_qualification, current_qualification| %>
<p>
<% (current_qualification.istqualifikation).times do %>
<%= image_tag("black.png") %>
<% end %>
<% (expected_qualification.sollqualifikation - current_qualification.istqualifikation).times do %>
<%= image_tag("grey.png") %>
<% end %>
</p>
<% end %> …
Run Code Online (Sandbox Code Playgroud) 我想将ruby代码嵌入我的链接名称.现在我试着像这样实现它:
<% @user.each do |user| %>
<li><%= link_to '<%= user.familyname %>, <%= user.forename %> ', user %> </li>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,Rails给我一个语法错误:
syntax error, unexpected $undefined, expecting ')'
...);@output_buffer.safe_concat('\', user %> </li>
... ^
Run Code Online (Sandbox Code Playgroud)
我需要在语法中进行哪些更改,以便此链接可以使用?
我想立即检索字符串中数据的纬度和经度.为了使用它,它必须转换为浮点数,所以我可以在这里使用它而不是浮点数:
//Create a region
mapview.mapType = MKMapTypeSatellite;
MKCoordinateRegion newRegion;
newRegion.center.latitude = 47.808435,
newRegion.center.longitude = 9.643743;
newRegion.span.latitudeDelta = 0.00472;
newRegion.span.longitudeDelta = 0.006899;
CLLocationCoordinate2D coordinate;
coordinate.latitude = 47.808435;
coordinate.longitude = 9.643743;
Run Code Online (Sandbox Code Playgroud)
我只知道如何将字符串转换为数据,但我不知道如何将其转换为浮点数.有人知道吗?
xcode4.2 ×2
actionview ×1
css ×1
diacritics ×1
html ×1
html-table ×1
hyperlink ×1
ios ×1
ipad ×1
javascript ×1
jquery ×1
objective-c ×1
storyboard ×1
utf-8 ×1
xcode ×1
xcode4 ×1