Posts

How to structure Rails link so that clicking it will update an ActiveRecord attribute -

I have two models, a property model and an app model. There are many properties in the application, and the property is an application_id in the property model, such as the application_id, which indicates the application associated with the property. I want to show a list of all the potential applications on the property show page, a link to the application which, if clicked, will update the application_id just in the property model in the ID of that application. Here is my relevant code: view / properties /show.html.erb select an application template : & Lt; Ol class = "microposts" & gt; & Lt;% @ owner.application.each do | Template | & Gt%; & Lt; Li & gt; & Lt;% = link_to "Application # {template.id}" ,: admin = & gt; "Attribute",: verb = & gt; "Update" ,: Method = & gt; : Put, application_id = & gt; Template.id% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt; / O...

html - How to prevent scrollbar from repositioning web page? -

I have a website with a center-aligned DIV. Now, some pages have to scroll, nothing. When I move from one type to the other, the page takes a few pixels aside as a scrollbar, is there any way to avoid this without clearly displaying the scrollbar on each page? overflow-y: scroll is correct, but you should use it with HTML tags, not On the body or on IE 7 you get a double scrollbar. Then the right CSS will be: html {overflow-y: scroll; }

mysql - Update a second table, using trigger -

I am trying to create a simple trigger, but, if I media Price comes from @total or @sum then the value on Proto is that I already have the option to test the option for "1" or "1 + 1" Tested to see if I was not updating properly or the problem was the operation itself. DELIMITER $$ Start triggering ratings before joining the rating for each line SET @total = @total + 1; SET @sum = NEW.stars + @sum; Update Prato P SET p.media = @ sum / @ total WHERE p.id = 1; End; $$ DELIMITER; Any ideology? I triggers on for each line . I thought, every time it was updated, it would move to run all the rows but, instead, it is implemented for each line which was updated , which could makes. This was my last result of the trigger, to add and update ratings (which prato ) DELIMITER $$ After inserting the trigger, after putting the INSERT on the rating for each line, if- (New.food_id is not empty) then SET @ media = (SELECT SUM (stars)) for ratings whe...

sql - How to do this dynamic where clause in EF -

Some advice about how to deal with the following selected queries with EF * Note, I Need help with SELECT only via e-mail. Insert a table table or stuff for a sample of my table structure. Create sample SampleTable value (1, 'GoodData'), (2, 'BetterData'), (2, 'whatever' Select from where SampleTable (* 10, 'GoodData') * Fu = 2 and Bar = 'BetterData') or (Fu = 1 and Bar = 'GoodData') --There these lines 'or' lines leave the table SampleTable Here are a couple of methods of extension: Public Static Class PredicateBuilder {Public Static Expression & lt; Funk & Lt; T, boolean & gt; & Gt; True & lt; T & gt; () {Return F = & gt; truth; } Public steady expression & lt; Func & lt; T, bool & gt; & Gt; Wrong & lt; T & gt; () {Return f = & gt; false; } Public steady expression & lt; Func & lt; T, bool & gt; & Gt; Or & lt; T & gt; (This expression ...

express - basic node.js tutorial error Object function router(req, res, next) has no method init -

I'm new to Express and WebStorm and I'm working on a simple tutorial Believe that I have followed all the instructions correctly and have fixed the type of site on (user vs. users etc.) Finally, I get the following error: / usr / bin / node app.js /home/admin/WebstormProjects/MyNode/app.js:61 users.init (); ^ Type Error: Object Function Router (Rick, Race, Next) {Router Handle (Rake, Race, Next); } There is no way 'init' on the object. & Lt; Anonymous & gt; (Module Js: 456: 26) on the object. Function module.load (module .js: 356: 32) function. Function on module._load (module .js: 312: 12) Module.Ranneman (module .js: 497: 10) at startup (node. Js: 119: 16) at node.js: 902: 3 end process with exit code 8 me It seems that this express edition is due to incompatibility. I had read the change doctor for Express 4, but I still can not debug this error You must change the router with exports.init () .init () : router.init = function () {user...

python - Checking a variable -

Currently I have a code that leads to vectors and creates one-third: b category (2047): For a boundary (B + 1,2048): Vector 1 = (L [B] [0], L [B] [1], L [B] [2]) Vector 2 = (L [A] [0], L [A] [1], L [A] [2]) X = Vector 1 Y = Vector 2 Vector 3 = List (NP. Array (X) - NP Array (Y)) Dot Product = Decrease (Operator.ed, map (operator.mult, vector3, vector3)) DP = dot product ** 5.Data_Point = DPB N = Int (DP / Bin_vidth) if the owner & lt; Num_bins: bins [bin] [2] + = 1.0 / bin_volumes [bin] ps b = 36771.881 but I want to say that if (vector 3 dot product with b) (b Dot product b) / 2 then vector 3 = vector 3 - b and (vector 3 dot product B) (B-dot product with B) / 2 > Then vector 3 = vector 3 + b How do I add it to my loop, so that it will check vector 3 for these two conditions for each vector 3? The package is being used: Import operator import matplotlib.pyplot plt as import npg as numpy Current Code: Border for Border = 36771.881 (2047): For a boundar...

decimal - In C#, why is this conversion causing an "Input string was not in a correct format." error? -

I have a code that reads a number (but comes in the form of a string) and I convert it to a byte I am trying to Normally the value is between 0 and 1 (like .25) and the below code works fine, but now I came to a negative value, especially "-1" and Trying to understand why this code is blowing: Public Static Bite GetByteVal (Detector Detroit, String Caption) {var val = dataRow.GetValue (Caption). Ostring (). Trim (); If (! String.IsNullOrEmpty (val)) {decimal converted val = decimals Purse (val, number style.alveexent | number equals; approbatory decimals) * 100; If (Convertvalle> = 0) {Return (byte) (converted veal); } Other {return (byte) 0; }} Return (Byte) 0; } When "val" variable comes in the form of "-1", I get an exception on this line: decimal converted val = decimal . Pars (Val, Number Style) Allow, Expand | Number Style, Allow, EmployPoint) * 100; which says: The input string was not in the correct format You must t...