renaming routes in rails 3 - ruby-on-rails-3

I'm new to this, so I'm not expecting that anyone tell me how to do it, just whether it's possible. If so, I'll continue to melt my brain with the docs.
I've been asked to change /markets/4/articles/32
to /markets/111111/articles/999999 where 111111 is in the remoteID field of the markets table and 999999 is in the remoteID field of the articles table.
The reason for this is that an external system will be creating the new records in the RoR app and inserting ITS id into the remoteID field. The next time it goes to update the record, it won't know the RoR ids without creating some kind of lookup.
From what I've seen, it can't be done. Maybe I'm just not looking hard enough?
Thanks,
Kelp

It should be possible, it probably can be changed to something like:
/markets/:market_remote_id/articles/:article_remote_id
It will then be available as params[:market_remote_id] and params[:article_remote_id] in your controller
Have a look at http://guides.rubyonrails.org/routing.html#dynamic-segments for the full story

Related

Can a table field be founded and then updated with a value in mvc Controller

yeah so the question is pretty simple: Can a table field be found using and ID and then updated with a value in mvc Controller?
And before anyone gets downvote crazy... I have no example because I don't know how to do this... it's not a home work question or any other things that you down vote on this site. It's a simple question that I need an answer and a example.
I now you can use the .find to and pass the ID... to a dataset but there is nothing I can find that shows you how to edit the values in the table once you find it.
So this part I get, This will allow me to find the the id with in the dataset.
TEST_DS tEST_DS = db.TEST_DS.Find(id);
if (tEST_DS == null)
{
return HttpNotFound();
}
Also I know that you see a call to the database like This
db.TEST_TABLE.Add(TEST_DS);
I don't see an option for edit or anything like that.
The task is to update a table field, The field is a status field so when the user makes a change on the mvc create form. When they create a record I want to mark a different table's status field with a number that represents a record was created.
Did a search did not see anything.. thanks may be something mvc can't do because of it's limitations or something.
If you do answer question I will need an example of a link to an example on how to do it. Thanks!!
I was able to make this work some I will post It there for others as they might have the same issues when dealing that mvc limitations and such.
So the answer is to simply have your data table in the dbcontext that you need to edit...
The code would not post.. it asking for 4 spaces and I gave it 4 spaces and it did not work so I added a picture.
See CodeAnswer Image

TDBGrid where is the SQL WHERE condition?

I am working on an already started Delphi project where there is a TDBGrid. The grid seems to be filled by a TADOTable that refer to a Bill table in the dataset.
It display a bill by PkBill. I can't seem to find where in the design or in code someone told to load only for this pk.
I need to load multiples Pk at the same time. I'm used to create programmatically a TADOQuery, create a connection, write my SQL code, then do what I want with the result. With those objects/controls, I just don't know where to do that.
Thanks for the help and clarity!
Check TADOTable.MasterSource to see if it's in the Master-Detail relationship.
Or you could check TADOTable.Filtered and TADOTable.Filter to see if it's being filtered by PkBill.

Table structure for Messages System

Hi i need to design a messaging system like facebook. I was thinking to build table similar
(source: serviciipeweb.ro)
where i can store olderMessage in another table so i can make quicker query in Message Main table...
but i cant resolve the problem about deleting messaging. If a user delete a message the other one should still read it.
How can i build it?
I googled but i didnt find anything.
P.S: I must use SQL-SERVER
Thanks
Create two fields in your Message table:
DeletedByFrom
DeletedByTo
Filter your results on this:
where DeletedByFrom = False
So you only get the rows that weren't deleted (in this case by the 'From' user)

Need a strategy for an efficient autocomplete in Rails across multiple attributes

I have a form for submitting an order, and I need an autocomplete field that searches across three attributes in the associated customer model: first name, last name, and customer_number (as opposed to customer.id). I know about the rails3-jquery-autocomplete gem found here http://github.com/crowdint/rails3-jquery-autocomplete, and got it working well, but a question has occurred to me -- is there a more efficient way to make the autocomplete work without having to query the db every time?
The other solution that occurred to me is to create a new indexed attribute in the customer model -- call it autocomplete_data. Whenever a new customer is added via the usual new customer form, an :after_create callback could populate the field. Would this speed up the performance? Or am I overthinking it?
UPDATE
I'm embarassed to say that I just didn't search hard enough the first time around -- I think this actually answers my question:
Rails: Efficiently searching by both firstname and surname

what is the best way to record users searches and count how many times it has been queried?

I am not sure what SQL is exactly, databases I think, would SQL be the thing to use?
I want it so that when a user types into a search box it displays a "did-you-mean" box, that also shows how many other people used that term but I will do later ;)
currently I just want the text to be saved into database (?) and also how many times it's been done.
(new to stackoverflow so sorry if format/whatever is bad)
You just need a three table named something like search_queries which has columns for: id, search_text, and count. Everytime somebody searches just increment the count column where search_text is equal to what they searched for. This is a really broad question though and you need to start by learning the basics and report back here with more specific questions.