Ruby on Rails API和Web服务(Ruby on Rails API and web services)
我是Web应用程序开发的新手,我有一个非常noob的问题。 据我所知,可以使用Rails编写Web应用程序的后端 - 模型,业务逻辑等,并使用HTML,CSS Javascript(不使用Rail的表单助手,嵌入式ruby等)编写后端 - 视图。)并且所述视图将呈现数据暴露Rails API并向其发出AJAX请求。 每次我用Google搜索“rails ajax requests API”时,我只找到了解释如何使用AJAX w / embedded ruby而不是教程的教程,这些教程明确区分了如何制作Rails API并使AJAX请求呈现数据。 所以我的问题是:
1)如果上述任何陈述不正确,您能告诉我吗?
2)有人能指点我帮助我理解上述主题的理论和实现的教程吗?
谢谢!
I am fairly new to web application development and I have a pretty noob question. As I understand, it is possible to write the backend of a web application - models, business logic, etc. using Rails and write the backend - the view - using just HTML, CSS Javascript (without using Rail's form helpers, embedded ruby, etc.) and that the said view would render data exposing a Rails API and making AJAX requests to it. Everytime I googled "rails ajax requests API" I have only found tutorials that explain how to use AJAX w/ embedded ruby instead of tutorials that clearly separate how to make a Rails API and make AJAX requests to render data. So my questions are:
1) If any of the above statements are incorrect, could you let me know?
2) Can someone point me to tutorials that help me understand the theory and implementation of the aforementioned topics?
Thanks!
原文:
最满意答案
尝试:
UPDATE news n JOIN news_in_category nic ON n.id = nic.newsId SET n.categoryID = nic.newsCategoryId
看起来你可能有一个冗余的功能依赖:
newsId -> categoryId
。 如果是这样,您可以在运行上述查询后删除news_in_category
表而不会丢失任何信息。Try:
UPDATE news n JOIN news_in_category nic ON n.id = nic.newsId SET n.categoryID = nic.newsCategoryId
It looks like you might have a redundant functional dependency:
newsId -> categoryId
. If so, you could drop thenews_in_category
table without any loss of information, after running the query above.
相关问答
更多-
只需在数据库中运行数学运算: update myTable set counter = counter + 1 where id = 'someValue'; Just run the math in the database: update myTable set counter = counter + 1 where id = 'someValue';
-
在mysql中,您可以在更新中使用联接来实现预期结果: update table2 t2 inner join table1 t1 on t2.rand=t1.rand set t2.cpn=t1.cpn In mysql you can use joins in updates to achive the expected results: update table2 t2 inner join table1 t1 on t2.rand=t1.rand set t2.cpn=t1.cpn
-
我想你想要的查询: SELECT A.filed_title,B.field_description FROM field_title_table A,field_description_table B WHERE A.entityid =B.entityid AND (A.filed_title LIKE '%your_keyword%' OR B.field_description LIKE '%your_keyword%' ) 我测试了它并且工作了 我认为我得到了你所期望的,你不能在查询中做条 ...
-
Excel VBA根据列名称将数据从表移动到表(Excel VBA to move data from table to table based on column name)[2023-04-07]
Do While i <= SourceTableColumnCount ColumnName = sourceTable.HeaderRowRange(i).Value On Error Resume Next DestColumnIndex = destTable.Range.Find(ColumnName, MatchCase:=True, SearchFormat:=False, SearchOrder:=xlByCol ... -
以下是涵盖条件1和条件2的“CELL”/“AP”部分的查询。 此查询使用COALESCE获得最大简洁性,可以使用CASE表达式替换它。 数字1000000是一个任意大数字,以确保SUBSTRING返回整个字符串。 如果您的字符串可能大于1000000个字符,请将数字更改为更大的字符。 DROP TABLE #TestData CREATE TABLE #TestData( Col VARCHAR( 100 )) INSERT INTO #TestData VALUES ( 'PU# HH55555 ...
-
您可以使用函数RAND()随机排序行并取第一行。 SELECT * FROM AllRows ORDER BY RAND()LIMIT 1,1 Thank you to all, but I have come up to do it this way: $accCount = mysqli_query($connect, "SELECT * FROM AllRows"); $accCount = mysqli_num_rows($accCount); $RandAcc = rand(0, $accCoun ...
-
Insert Table2( Column1 ) Select Column1 From Table1 As T1 Where Not Exists ( Select 1 From Table2 As T2 Where T2.Column1 = T1.Column1 ) Insert Table2( Column1 ) Select Colu ...
-
使用HallGroupID连接两个表,并从HallGroup表中select Name 。 Select HG.Name,HS.ShowSeatID,HS.Color,HS.Price,HS.SeatRow,HS.SeatNumber,HS.IsReserved FROM HallSeat HS JOIN HallGroup HG ON HG.HallGroupID = HS.HallGroupID Join both the tables with HallGroupID and select Na ...
-
尝试: UPDATE news n JOIN news_in_category nic ON n.id = nic.newsId SET n.categoryID = nic.newsCategoryId 看起来你可能有一个冗余的功能依赖: newsId -> categoryId 。 如果是这样,您可以在运行上述查询后删除news_in_category表而不会丢失任何信息。 Try: UPDATE news n JOIN news_in_category nic ON n.id = nic.newsI ...
-
不,没有标记每一列就没有办法做到这一点。 SQL中没有SELECT *_except_for_a_few_columns语法 您可以从INFORMATION_SCHEMA生成列列表,这样您就可以减少繁琐的输入: SELECT GROUP_CONCAT(column_name ORDER BY ordinal_position) AS _cols FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'mydatabase' AND table_name = ...